Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1124

Re: How to sort String array A based on int array B

From Eric Sosman <esosman@ieee-dot-org.invalid>
Newsgroups comp.lang.java.help
Subject Re: How to sort String array A based on int array B
Date 2011-09-23 20:45 -0400
Organization A noiseless patient Spider
Message-ID <j5j982$1g3$1@dont-email.me> (permalink)
References <1k2n77ltdv7ml661pa9a2g63j8q5l1c66g@4ax.com> <j5gqu1$16g$1@dont-email.me> <ep3p77d85jvattd70agv77gl7g60a2iuvf@4ax.com>

Show all headers | View raw


On 9/23/2011 10:13 AM, Thee Chicago Wolf [MVP] wrote:
> [...]
> Yes, rank[k] is already sorted from most popular to least popular (1
> being most popular and 6 being least). artist [k] is scrambled (read:
> unsorted) but *does* have its know rank preceding it (i.e., 6_ or 4_).
> After all, how could you sort a bunch of Artists (read: String items)
> without already knowing their current / existing ranking? To me that
> doesn't seem possible. Or I just don't know how to do that (yet). ^_^

     That's the crux of the homework problem.  Given a telephone
directory sorted by name, produce a directory sorted by number.
Given a list of politicians' names and a corresponding list of
the number of votes each received, produce a list ordered by vote
count.  Given a list of planet names and a list of their masses,
produce a list ordered by mass.

     Various people have given you the broad outline.  First, determine
what governs the desired sort order: telephone number, vote count,
planetary mass.  This tells you which list is to be sorted, and which
list is just to be carried along.  Sort the chosen list with whatever
technique you fancy, but each time you move an element of that list,
move the corresponding element of the other list similarly.

     Back to the telephone directory: What influence does a person's
name have on his final position in the list?  None -- it's entirely
determined by his phone number.  He could go to court and have his
name legally changed from Aaron Aardvark to Zuniga Zymanski, and his
position in the sorted list would remain unaltered.  Since his name
does not affect the outcome (his phone number is the only thing that
matters), no comparison of his name to any other name or to any other
thing at all can affect the outcome.  Therefore, his name need not
enter into any comparisons; all the comparisons involve his phone
number and only his phone number.

     I hope that's enough to get you started.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

How to sort String array A based on int array B "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-22 14:31 -0500
  Re: How to sort String array A based on int array B markspace <-@.> - 2011-09-22 15:38 -0700
    Re: How to sort String array A based on int array B "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-23 08:51 -0500
      Re: How to sort String array A based on int array B Patricia Shanahan <pats@acm.org> - 2011-09-23 07:23 -0700
        Re: How to sort String array A based on int array B "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-23 10:51 -0500
          Re: How to sort String array A based on int array B Patricia Shanahan <pats@acm.org> - 2011-09-23 09:59 -0700
            Re: How to sort String array A based on int array B "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-23 14:31 -0500
              Re: How to sort String array A based on int array B Patricia Shanahan <pats@acm.org> - 2011-09-23 12:39 -0700
              Re: How to sort String array A based on int array B "Charles Hottel" <chottel@earthlink.net> - 2011-09-23 17:42 -0400
                Re: How to sort String array A based on int array B "Thee Chicago Wolf (MVP)" <.@.> - 2011-09-23 20:27 -0500
                Re: How to sort String array A based on int array B Patricia Shanahan <pats@acm.org> - 2011-09-23 18:39 -0700
                Re: How to sort String array A based on int array B "Thee Chicago Wolf (MVP)" <.@.> - 2011-09-26 08:37 -0500
                Re: How to sort String array A based on int array B Patricia Shanahan <pats@acm.org> - 2011-09-26 08:04 -0700
                Re: How to sort String array A based on int array B "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-27 13:47 -0500
                Re: How to sort String array A based on int array B "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-27 13:59 -0500
                Re: How to sort String array A based on int array B Lew <lewbloch@gmail.com> - 2011-09-27 12:25 -0700
                Re: How to sort String array A based on int array B Lew <lewbloch@gmail.com> - 2011-09-26 09:00 -0700
                Re: How to sort String array A based on int array B "Charles Hottel" <chottel@earthlink.net> - 2011-09-23 23:31 -0400
                Re: How to sort String array A based on int array B "Thee Chicago Wolf (MVP)" <.@.> - 2011-09-26 08:29 -0500
  Re: How to sort String array A based on int array B Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-22 22:28 -0400
    Re: How to sort String array A based on int array B "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-23 09:13 -0500
      Re: How to sort String array A based on int array B Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-23 20:45 -0400
  Re: How to sort String array A based on int array B Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 02:28 -0700
    Re: How to sort String array A based on int array B "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-23 09:14 -0500
  Re: How to sort String array A based on int array B Roedy Green <see_website@mindprod.com.invalid> - 2011-09-25 00:46 -0700

csiph-web