2

I know, I've found many examples to sort an Object. But that makes me a little bit confused (I am not so pro to check wich is the fastest and cleanest method for me).

I hope somebody can help.

My Object looks like

tt_results = {};
tt_results[6815631] = new Array('85', 'blibee', 'blaerb', 'bluo', 'tkone', 'tkeeee_seve', '382261471' );
tt_results[1563157] = new Array('25', 'blib', 'blab', 'bluerro', 'tkerone', 'tk_seve', '382266851' ); 

I want to sort the timestamp.

Thanks in advance!

Peter

Andy E
  • 338,112
  • 86
  • 474
  • 445
Peter
  • 11,413
  • 31
  • 100
  • 152

2 Answers2

4

As has been mentioned in the comment you cannot sort objects.

In terms of general js performance a good resource for x-browser tests & results check out jsperf. There is an array sort test here

redsquare
  • 78,161
  • 20
  • 151
  • 159
3

See my answer to a similar question here: Trying to sort a custom JavaScript object

Basically, you can't sort objects themselves - it doesn't make sense. But you can process the object in sorted order by sorting the keys and then iterating over the sorted keys.

Community
  • 1
  • 1
slebetman
  • 109,858
  • 19
  • 140
  • 171