javascript Jquery - 排序对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3716195/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery - Sort object
提问by Peter
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).
我知道,我找到了很多对 Object 进行排序的示例。但这让我有点困惑(我不是很专业,无法检查这对我来说是最快和最干净的方法)。
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
彼得
回答by redsquare
回答by slebetman
See my answer to a similar question here: Trying to sort a custom JavaScript object
在此处查看我对类似问题的回答:尝试对自定义 JavaScript 对象进行排序
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.
基本上,您不能自己对对象进行排序 - 这没有意义。但是您可以通过对键进行排序然后迭代已排序的键来按排序顺序处理对象。

