有谁能够帮我。如何在jquery中对数据进行排序 [英] can anybody help me. how to sort data in jquery

查看:62
本文介绍了有谁能够帮我。如何在jquery中对数据进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有10条记录,我已经创建了一个数组然后我将如何通过使用排序来获取第9条记录

i have 10 records and i have create a array then how i will get 9th record from aaray by using sorting

推荐答案

只需使用索引器即可获得第9条记录元素,



Just use the indexer to get the 9th element,

// return the 9th element of the array
var el = arr[8];





数组是从0开始的,因此8将返回第9个索引处的元素。对于排序,您可以调用对象的 .sort()函数;有关更多信息,请参阅 MDN [ ^ ]。您还应该阅读有关程序描述的报价:





Arrays are 0-based, so 8 would return the element at 9th index. For sorting, you can call the .sort() function of the object; for more please refer MDN[^]. You should also read the quotation about the description of the procedure:

Quote:

元素通过将它们转换为字符串并按Unicode代码点顺序比较字符串进行排序。例如,Cherry出现在banana之前。在数字排序中,9出现在80之前,但由于数字被转换为字符串,80以Unicode顺序出现在9之前。

Elements are sorted by converting them to strings and comparing strings in Unicode code point order. For example, "Cherry" comes before "banana". In a numeric sort, 9 comes before 80, but because numbers are converted to strings, "80" comes before "9" in Unicode order.





希望您能从MDN中了解如何执行此操作。



Hopefully, you will get the idea for how to doing this from MDN.


这是如何:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort [ ^ ]。br />


-SA
This is how: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort[^].

—SA


检查一下,



http://jsfiddle.net/King_Fisher/opuu2u9w/ [ ^ ]





参考这个:



http://www.w3schools.com/jsref/jsref_sort.asp [ ^ ]
Check this,

http://jsfiddle.net/King_Fisher/opuu2u9w/[^]


Refer this:

http://www.w3schools.com/jsref/jsref_sort.asp[^]


这篇关于有谁能够帮我。如何在jquery中对数据进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆