August 20, 2003 Sort the array of objects | ||||
---|---|---|---|---|
| ||||
I found if I sort an array of objects, like: Object[] array; array ~= new Object; array ~= new Object; ..... array.sort; Them will be sorted by address of object. Why not sort them by overloaded operator Object.cmp() ? |
August 28, 2003 Re: Sort the array of objects | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kai | "Kai" <Kai_member@pathlink.com> wrote in message news:bhvlu4$1sd7$1@digitaldaemon.com... > I found if I sort an array of objects, like: > > Object[] array; > array ~= new Object; > array ~= new Object; > ..... > > array.sort; > > Them will be sorted by address of object. > Why not sort them by overloaded operator Object.cmp() ? It does sort by Object.cmp(). The default implementation of Object.cmp() sorts by address. See phobos/object.d |
Copyright © 1999-2021 by the D Language Foundation