sort struct of arrays

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 9 07:23:40 PDT 2014


If you have an array of structs, such as...

      struct Foo
      {
          int x;
          int y;
      }

      Foo[] foos;

...and you wanted to sort the foos then you'd do something like...

      foos.sort!(a.x < b.x),

..and, of course, both of the fields x and y get sorted together.
If you have a so-called struct of arrays, or an equivalent
situation, such as...

      int[] fooX;
      int[] fooY;

...is there a simple way to sort fooX and fooY
"together"/coherently (keyed on, say, fooX), using the standard
lib?


More information about the Digitalmars-d-learn mailing list