|
Say I have an array filled with times, but in seconds accurate down to the millisecond. How would I go about sorting these in order from highest to lowest value? I have tried this method out: http://www.zparacha.com/sort_numeric_arrays/#.T2KysRFuksI But, it only seems to sort intergers. I need it to sort down to the decimal.
(comments are locked)
|
|
If you're not worried about the internals of the sort, letting the .NET framework take care of it for you may save some headaches. You didn't mention which particular data structure you're using, so I'll offer an example which includes some popular choices. Whats a data structure?? I'm a javascript guy, so I'm a little confused.. My array already contains the floats. I just have to put them in a different order. I'm not seeing what you are doing with 300.1 or 200.2, because those should just already be in the array to start with. I have no idea what .Net, pragma strict, or import System Collections Generic even means. :/ It's just a simple array - 8 floats that are completely out of order. I am trying to judge a timed race where 8 cars each finish with a different time. The question is: who took first place, second place, third place.. etc. The times have to be put in order, and then I can say: if(myTime==finishedTime[1])me="first place"; See what I mean now? It shouldn't be so complicated. I just can't figure out why that example I linked to above rounds my floats up to the nearest whole number.
Mar 16 '12 at 11:58 PM
Rush3fan
(comments are locked)
|

Did you try that code you linked to? I don't think it would care if it were ints or floats
Yea.. it worked, but, for some reason, it rounded everything up. One thing I tried doing is multiplying by 10000 so that the decimal places would be counted for, but it's really a pain to do it that way.