Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1259
| From | "Alex Mentis" <foo@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: Array sort problem. |
| Date | 2011-10-17 21:14 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <j7i5s3$7l6$1@dont-email.me> (permalink) |
| References | <j7i0eo$kfs$1@speranza.aioe.org> |
Warren Tang wrote: > Hi,everyone > > I have an array: > > index value > 0 33 > 1 22 > 2 44 > 3 11 > > Now I'd like to sort it, but I also need to preserve the original > index, like this: > > newIndex originalIndex sortedValue > 0 3 11 > 1 1 22 > 2 0 33 > 3 2 44 > > How can this be done conveniently in Java? > > Regards, > Warren Tang I imagine you'd have to go through the array of values and turn it into an array of objects that contain fields for both the original index and value. Then sort the new array based on the values.
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
Array sort problem. Warren Tang <nospam@tangcs.com> - 2011-10-18 03:42 +0800
Re: Array sort problem. "Alex Mentis" <foo@invalid.invalid> - 2011-10-17 21:14 +0000
Re: Array sort problem. Lew <lewbloch@gmail.com> - 2011-10-17 15:54 -0700
Re: Array sort problem. Warren Tang <nospam@tangcs.com> - 2011-10-19 10:59 +0800
Re: Array sort problem. Roedy Green <see_website@mindprod.com.invalid> - 2011-10-19 15:22 -0700
csiph-web