i want if i sort out the values of the values[], it will be sorted but the variable they are originally assigned on will follow the sequence of the sorted values...
any ideas to do this?
i am lacking out of ideas that's why i asked help here.
hoping somebody could lend me a hand.
thanks in advance.
Ireneusz Kordal
Ranch Hand
Joined: Jun 21, 2008
Posts: 423
posted
0
You could create a wrapper class for your variable-name / value pair like this:
provide hashCode() and compareTo() methods based on Integer values, then create an ArrayList of these wrapper objects
and sort this ArrayList with Collections.sort method. Finally, iterate trough the array and print name / value pairs.
You could also create an array of these objects and sort it with Arrays.sort.
Jhedzkie Skies
Ranch Hand
Joined: Oct 28, 2009
Posts: 118
posted
0
thanks Ireneusz... i'll try to study hashes.
it is something new for me...
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
posted
0
Ireneusz Kordal wrote:You could create a wrapper class for your variable-name / value pair like this:
I think that you'll also want to make this wrapper class implement Comparable<IntWrapper>
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.