Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news-out.readnews.com!news-xxxfer.readnews.com!s09-11.readnews.com!unm2.readnews.com.POSTED!not-for-mail X-Trace: DXC=aVHHFE:hlD?gMM545i4dR3k\2KDSF=2@2FV0LA4MIjQ;mTIDj6@1Wa<^]]CW6JBja9TA`X]=O@ZU>Z9GT_UZ?S]?^D3[^?;YcN0o3R^HBiTkA8:Wa6U]`:5E2LoRkGiP7ZW3 X-Complaints-To: killthespammer@usenetmonster.com From: "Thee Chicago Wolf [MVP]" <.@.> Newsgroups: comp.lang.java.help Subject: Re: How to sort String array A based on int array B Date: Fri, 23 Sep 2011 10:51:25 -0500 Organization: . Reply-To: . Message-ID: References: <1k2n77ltdv7ml661pa9a2g63j8q5l1c66g@4ax.com> <822p77tjmlsdrp2r7so1ko70igu9fascn6@4ax.com> X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: yes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 46 NNTP-Posting-Host: 66ae19b3.newsreader.readnews.com Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.help:1116 >On 9/23/2011 6:51 AM, Thee Chicago Wolf [MVP] wrote: >>> On 9/22/2011 12:31 PM, Thee Chicago Wolf [MVP] wrote: >>> >>>> The trouble I am having is sorting array B based on array A. >>> >>> >>> I don't doubt that. I'm having trouble understanding what "based on" >>> means here. Can you elaborate? What actual operation do you want to >>> preform on A and B, based on what criteria? >> >> Ok, after reading my post I can see that I was not quite as clear as I >> could have been. >> >> So I have two arrays: A and B. Array A is an int array (I think I had >> it backwards in my original description) and array B is a String >> array. Array A is already ordered from 1 - 6 in ascending order and is >> basically a rank order with 1 being most popular, 2 = less popular >> than 1, 3 = less so than 2, etc. Array B is the artist info, >> scrambled, but each artist is defined by their appropriate popularity >> with a #_ naming convention preceding the artist name and song title. >> I figured that array B had to have some defining characteristic about >> it else there would be no way to order a bunch of String info to a >> corresponding rank without knowing the current artist ranking. > >You say "I figured" so presumably that part of the description is not an >explicit part of the original problem definition. How confident are you >that B should contain ranking information? If it does, the array A seems >superfluous, and the problem is simply one of sorting B. > >There are alternative interpretations of the rest of your comments that >would give meaning to both arrays. Here is the original requirement: Modify any of the sort algorithms to sort a secondary array B based on the sorting order of A (that is akin to say: sort the titles of the songs (B) based on their rank (A). I chose to add Artist info in addition to song title. This is why I specifically added the #_ (read as number underscore) to the String array else I figured there was no easy way to sort them based on a rank. Meaning, you can't compare an int to a String. In my mind, I thought that adding the #_ to the beginning of the String item would make it easier to sort it. Does that make sense? - Thee Chicago Wolf [MVP]