Thanks for some of your replies for the lst post i need small
modification in that post .. i want to sort the salary in descending
order. i have explained the same quesion again....
Hi all,
I want to sort the objects of array based on two attributes.I want
sort an employee class based on his salary in descecding order and name
, so that if two
person has same salary it should be sorted with name.
Lets say for example the employee objects has following name and
salary.
name salary
d 100
c 200
b 50
a 100
so in this case the result which i expect is
name salary
b 200
a 100
d 100
c 50
Note:In the above example for salary 100 the sorting is done
alphabetically, but initially(before sorting) 'd' came first and then
'a' came.so basically i want to sort the array with more than one order.
Can any one help me to solve it ??
Thanks for some of your replies for the lst post i need small
modification in that post .. i want to sort the salary in descending
order. i have explained the same quesion again....
Hi all,
I want to sort the objects of array based on two attributes.I want
sort an employee class based on his salary in descecding order and name
, so that if two
person has same salary it should be sorted with name.
Lets say for example the employee objects has following name and
salary.
name salary
d 100
c 200
b 50
a 100
so in this case the result which i expect is
name salary
b 200
a 100
d 100
c 50
Note:In the above example for salary 100 the sorting is done
alphabetically, but initially(before sorting) 'd' came first and then
'a' came.so basically i want to sort the array with more than one order.
Can any one help me to solve it ??
Thanks for some of your replies for the lst post i need small
modification in that post .. i want to sort the salary in descending
order. i have explained the same quesion again....
I came up with this which is sub par as I test for a condition twice so
stay tuned for a better solution..
Thanks for some of your replies for the lst post i need small
modification in that post .. i want to sort the salary in descending
order. i have explained the same quesion again....
I came up with this which is sub par as I test for a condition twice so
stay tuned for a better solution..
On 3/26/07, Alex Young <alex@blackkettle.org> wrote:
senthil wrote:
> Thanks for some of your replies for the lst post i need small
> modification in that post .. i want to sort the salary in descending
> order. i have explained the same quesion again....
>
> Hi all,
> I want to sort the objects of array based on two attributes.I want
> sort an employee class based on his salary in descecding order and name
> , so that if two
> person has same salary it should be sorted with name.
> Lets say for example the employee objects has following name and
> salary.
>
> name salary
> d 100
> c 200
> b 50
> a 100
>
> so in this case the result which i expect is
>
> name salary
> b 200
> a 100
> d 100
> c 50
>
> Note:In the above example for salary 100 the sorting is done
> alphabetically, but initially(before sorting) 'd' came first and then
> 'a' came.so basically i want to sort the array with more than one order.
> Can any one help me to solve it ??
>
In this case, just invert the salary:
That's lovely. My brain wandered off down the String#invert route, and I ended up getting tied in knots over multibyte encodings. Reverse is a *much* nicer trick.
···
On 3/26/07, Alex Young <alex@blackkettle.org> wrote: