Re: Sorting a vector based on another datas



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}

These are vectors, but not Vectors. The conventional Java term for these structures is "array".

It's because i sorted the models' vector based on ranking vector, and
it could accept duplicate datas;
So how can i do that ??????

I think about do a bubble sort in ranking vector and when the
condition met (like ranking[0] > ranking[1]) I swap both vectors, but
I don't think it's the best way. There is another one ?

You'd be better off declaring a class type that holds the value and rank, then sort an array or List of that type based on a Comparator that examines the rank.

- Lew
.



Relevant Pages

  • RE: How EXACTLY does Indexing Service determine rank
    ... the point that they are adjacent becoming a phrase and raising the rank ... The ranking mechanism is weighted so that the more highly inflected ... the linguistic engine and ranking algorithm ... Indexing Service is based on ranking formulas that are used everywhere from ...
    (microsoft.public.inetserver.indexserver)
  • Re: Increasing your PAGE RANK
    ... >> Participating in link schemes is a way to increase page rank, ... so the site 'spam ranking' will ... I have a "useful links" page on one site for people who want ... > to do a link exchange. ...
    (alt.internet.search-engines)
  • Re: Integrating results from different pages? (No luck w/ INDEX &
    ... ranking for every player that has a ranking. ... Most of my source come in the format "Rank. ... Lastname" match a cell that is a formula that gives the same result? ... > Now you have all the names in sheet3 ...
    (microsoft.public.excel.misc)
  • RE: Ranking different groups in one column
    ... Thank you for the ranking different groups within one colmun formula: ... As you see, three regions, a bunch of store names and scores. ... Gary''s Student - gsnu200776 ... a.n.other user from this datasheet and just 'pulling' the rank no into the ...
    (microsoft.public.excel.misc)
  • Re: Sorting functionality
    ... application specific sql functionality. ... I have to implement a ranking ... a rank must be assigned to each tuple depending ... separate attribute in the same table. ...
    (comp.databases)