Atitit List table sorting Data solutions by field
1.1. sort UI1
1.1.1. C:\Users\Administrator\Desktop\00oa\com.attilax\ui\orderArrow.js1
1.2. The Sort method of the collection (recommended)2
1.3. Linq method supports SQL Multi-sorting (the most powerful method 2
1.4. Other sorting methods manual sorting 3
1.5. Js Edition sort 3
2. Sort the FAQ 4
1.1.
sort UI with call
The main arrow is the toggle mode.
<span id= "Avgtimearrow" >
<i class= "fa fa-chevron-circle-up fa-lg" ></i>
<i class= "fa fa-chevron-circle-down fa-lg" style= "Display:none" ></i>
</span>
Binding Sort Events
function Iniorderfun ()
{
Orderarrow_ini ("#avgtimeArrow", Alldata_r44, " Average time ", function (arr_ordered) {
Setpagecontrol (arr_ordered);});
1.1.1.
C:\Users\Administrator\Desktop\00oa\com.attilax\ui\orderArrow.js
function Orderarrow_ini (Jqobj,arrdata,fld,orderedeventhandler)
{
var upobj=$ (jqobj+ ". fa-chevron-circle-up");
var downobj=$ (jqobj+ ". Fa-chevron-circle-down");
Downobj.hide ();
$ (upobj). On (' click ', function () {
$ (this). Hide ();
Downobj.show ();
var arr_ordered= orderbydesc (ARRDATA,FLD);
Console.log (Json.stringify (arr_ordered));
Orderedeventhandler (arr_ordered);
});
Downobj.on (' click ', function () {
Downobj.hide ();
Upobj.show ();
var arr_ordered=orderbyasc (ARRDATA,FLD);
Console.log (Json.stringify (arr_ordered));
Orderedeventhandler (arr_ordered);
});
}
1.2.
The Sort method of the collection (recommended)
Return Arrdata.sort (function (A, b) {
var aval= (a[fld]);
if (aval==null)
aval=0;
var bval=b[fld];
if (bval==null)
Bval=0
var rzt= aval-bval;
return rzt;
});
The quickest way
1.3.
Linq method supports SQL Multi-sorting (the most powerful method
)
1.4.
Other sorting methods manual sorting 1.5.
Js Edition sort
JavaScript Document
function Orderbyasc (ARRDATA,FLD)
{
Return Arrdata.sort (function (A, b) {
var aval= (a[fld]);
if (aval==null)
aval=0;
var bval=b[fld];
if (bval==null)
Bval=0
var rzt= aval-bval;
return rzt;
});
}
Bubble Sort
function Bubblesort (ARRAY,FLD) {
var i = 0,
Len = Array.Length,
J, D;
for (; i < Len; i++) {
for (j = 0; J < Len; J + +) {
if (ARRAY[I][FLD] < ARRAY[J][FLD]) {
d = array[j];
ARRAY[J] = Array[i];
Array[i] = D;
}
}
}
return array;
}
function Orderbydesc (ARRDATA,FLD)
{
Return Arrdata.sort (function (A, b) {
var aval= (a[fld]);
if (aval==null)
aval=0;
var bval=b[fld];
if (bval==null)
Bval=0
var rzt= bval-aval;
return rzt;
});
}
2.
FAQ for sorting
Disorderly Order Problem:: May be caused by a null value ... Convert to 0 .
Atitit. the best way to use the sort in real life -----ATI Summary of sorting method . doc
JavaScript version of several common sorting algorithms -jun.lu- Blog Park . html
author :: Nickname: Old Wow's paw claw of Eagle idol iconoclast Image-smasher
Bird King "Bird Catcher Kok devout pious religious defender Defender of the Faith. Caracalla red cloak Caracalla red cloak king of beasts
abbreviation:: Emir Attilax Akbar Emile Atiraca
Full Name:: Emir Attilax Akbar bin Mahmud bin Attila bin Solomon bin Adam Al Rapanui Emile Atilax Akbaben Maham Solomon Ben Adam Arrapanui
Common name: Etila (Ayron), Email:[email protected]
title:Head of Uke headquarters, founder of Global Grid project,
Uke Friendship Association president Uke Hunting Association president Emir Uke Tribe chief Grand Chief,
Uke, Minister of Religious and Cultural Integration Affairs, Vice-Chairman of the Uke Reformation Commission
Uke system and chairman of the major conference committee, Uke Security Department Chief Brigade, Uke System Inspection Committee vice President,
UKE Chief CTO Software Division Director of Technical department deputy Director of Research and Development department Director of Product department deputy Manager Project department deputy Manager Uke Science and Technology research Institute Dean Uke Software Training Master
Uke Polynesia District chain Head of the area responsible for the Kingdom of Tonga Uke Kerr Glen, chain head, Line Is. district chain head, Uke Bouvet and South Georgia and South Sandwich Is. region chain Head
Uke, chairman of the Association of Software Standardization, vice president of Uke Database and storage Standardization Association
Uke, founder of Uke Hospital and Medical school, vice president of lifelong Education School
UEC, president of UECIP, director of UKE document Retrieval department, head of Department of image processing machine vision
Uke, chief Dean of the School of image processing and machine vision
Uke Outdoor Sports Association chairman of the resort chief Mayor Uke Press editor
reprint Please indicate source:Attilax's column? http://www.cnblogs.com/attilax/
--atiend V8
Atitit List table sorting Data solutions by field