Sorting array or AssocArrays by value.

BCS ao at pathlink.com
Sun May 4 14:13:03 PDT 2008


Reply to Frits,

> module test;
> import tango.io.Stdout;
> import tango.text.convert.Format;
> struct Pair {
>   int a, b;
>   int opCmp(Pair* other) {
>     if (a != other.a)
>       return typeid(typeof(a)).compare(&a, &other.a);
>     else
>       return typeid(typeof(b)).compare(&b, &other.b);
>   }
>   char[] toString() {
>     return Format("{}:{}", a, b);
>   }
> }


maybe that should be templated.

struct SortSet(K, V...) { ... }





More information about the Digitalmars-d mailing list