2 Dimensional Array Sorting

user1234 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 25 23:11:37 PDT 2017


On Saturday, 26 August 2017 at 06:01:15 UTC, Vino.B wrote:
> Hi,
>
>  Can someone provide me a example of sorting 2 Dimensional 
> Array containing Filename and Size, and should be sorted by 
> Size.
>
> From,
> Vino.B

void main(string[] args)
{
     import std.stdio;
     import std.algorithm.sorting;

     string[2][] nameAndSize = [["b", "2"], ["a", "1"]];
     auto s = nameAndSize.sort!((a,b) => a[0] < b[0] && a[1] < 
b[1]);
     writeln(s);
}


More information about the Digitalmars-d-learn mailing list