Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1109
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: How to sort String array A based on int array B |
| Date | 2011-09-23 02:28 -0700 |
| Organization | Canadian Mind Products |
| Message-ID | <itjo779f577i2pvsgdi34ohr753upqkr36@4ax.com> (permalink) |
| References | <1k2n77ltdv7ml661pa9a2g63j8q5l1c66g@4ax.com> |
On Thu, 22 Sep 2011 14:31:20 -0500, "Thee Chicago Wolf [MVP]" <.@.> wrote, quoted or indirectly quoted someone who said : >The trouble I am having is sorting array B based on array A. One's a >String the other's an int. I thought I could use something like >(Integer.valueOf(charAt(artist[i])) to do it. Am I on the right track >with somethig like that? You need to create some little glue objects that have enough information in them that your sort Comparator can decide order just with that. Typically if you wanted to put some strings in a particular order, your glue objects would have a String and an int snaffled from the array. Then the Comparator has all it needs to sort -- the int. If you are having trouble generating Comparator code, see http://mindprod.com/applet/comparatorcutter.html It will crank out Java code for them after selecting the fields to use in the sort. I was horrified at how voluminous comparators are in Java compared with the sort I built into my own language. At least this way you don't have to type all that bubblegum. Also I have posted source code for a number of simple sorts. See http://mindprod.com/jgloss/sort.html Make sure you use the standard Sun Comparator/Comparable in designing your sort. see http://mindprod.com/jgloss/comparator.html http://mindprod.com/jgloss/comparable.html It makes swapping out different algorithms very easy, and it makes it easy to change the sort criteria. -- Roedy Green Canadian Mind Products http://mindprod.com It should not be considered an error when the user starts something already started or stops something already stopped. This applies to browsers, services, editors... It is inexcusable to punish the user by requiring some elaborate sequence to atone, e.g. open the task editor, find and kill some processes.
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
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