Re: Sorting a vector based on another datas
- From: Kai Schwebke <realfreejack75@xxxxxxxx>
- Date: Wed, 31 Jan 2007 18:58:56 +0100
zelao.itu@xxxxxxxxx wrote:
Hey everybody, I'm having troubles with sorting a vector based in
another vector:
Example:
String [] models = {"Anna","Gisele","Yasmin"}
int [] ranking ={3,1,2}
....After sorting it might be this :
models = {"Gisele","Yasmin","Anna"}
ranking = {1,2,3}
Just put the strings as values in a TreeMap using
the ranking as key. The TreeMap then may be accessed sorted by the key
ordering (e.g. the values() method returns an ordered collection).
If you have a large number of elements bubble sort will be very slow --
it is the worst method to sort any kind of data.
Kai
.
- Follow-Ups:
- Re: Sorting a vector based on another datas
- From: Daniel Pitts
- Re: Sorting a vector based on another datas
- References:
- Sorting a vector based on another datas
- From: zelao.itu@xxxxxxxxx
- Sorting a vector based on another datas
- Prev by Date: Re: Two more multithreading questions
- Next by Date: Re: Tooltip on JComponent
- Previous by thread: Re: Sorting a vector based on another datas
- Next by thread: Re: Sorting a vector based on another datas
- Index(es):
Relevant Pages
|