| |||||||||||
array in deascending order Posted by RKM (RKM), 28 May 2003 Hi i am here again with another question if I have the following array: static float [] in1 = { 0,0,0,80,0,0,100,0,0,90,0,0,70,60}; first I want to sort it so I will have as the following array {100,90,80,70,60,0,0,0,0,0,0,0,0,0} Then I want an array of the positions of the first ordered values in the original array I mean that ,I must have the following {7,10,4,13,14,0,0,0,0,0} How can I 1.sort the array (in deascending order) 2.build an array of the positions of the first 10 ordered value (its position in the original array). Posted by admin (Graham Ellis), 28 May 2003 Here are the results you're looking for then (remember that Java gives array positions starting at 0):Code:
And here's an example of the code to do it; I've made heavy use of Java Utility classes as I really should be encouraging to use those rather than write your own maths routinse, but you may find a shorter way ... Code:
This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |