www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Sorting with unaryFun predicate

reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
Why isn't there an overload for `std.algorithm.sorting.sort` that 
takes a `unaryFun` lambda?

Something like

     x[].sort!"a.m";

sorting elements in `x` according to the value of element member 
`m` compared to the longer

     x[].sort!"a.m < b.m";
Jan 06 2017
next sibling parent =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Friday, 6 January 2017 at 15:36:42 UTC, Nordlöw wrote:
 Something like

     x[].sort!"a.m";
Perhaps under a different name `sortBy` x[].sortBy!"a.m";
Jan 06 2017
prev sibling parent =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Friday, 6 January 2017 at 15:36:42 UTC, Nordlöw wrote:
 Why isn't there an overload for `std.algorithm.sorting.sort` 
 that takes a `unaryFun` lambda?

     x[].sort!"a.m < b.m";
Oops, http://forum.dlang.org/post/nxdsmdimnfssqmeybuxp forum.dlang.org https://github.com/nordlow/phobos-next/blob/master/src/sort_ex.d Deja vu
Jan 06 2017