In ruby we can perform schwartzian transforms easily with the sort_by method. This allows sorting enumerators by any property.

For example to do a non case sensitive sort:

some_array.sort_by { |x| x.downcase }

Based on this Mathworks blog, I have ported the Matlab central code to a Toolbox on Github.

After Downloading the toolbox and adding the functions folder to your path.

addpath('../lib/nested_sort/function/');

Basic usage is:

A = struct('name', num2cell(1:4), 'value', {5,2,3,1});
B=sortStruct(A,'value');

B is A sorted by ‘value’.