How to sort things with Javascript or jQuery?

Coldblackice

[H]ard|Gawd
Joined
Aug 14, 2010
Messages
1,151
What Javascript or jQuery functions might I use to sort a smattering of elements on a page?

I'm not asking for a verbatim code, just what sort of functions might be useful or appropriate (even partly) to help accomplish this purpose. I'm looking for both Javascript functions and jQuery functions.

What I'm trying to do:

I often see pages where I'd like to sort or arrange a number of elements, like sorting book titles on a page into alphabetical order, or sorting a random scattering of dates into chronological order, etc. I'm attempting this only as a self-assigned example on my way to learning Javascript and jQuery.

I realize that, without giving a specific page or example, I'm impeding assistance on any element selection techniques and function suggestions, but I'm mostly looking for Javascript/jQuery functions/methods/ways that could/would be used to sort or arrange elements (rather than page-specific JS/jQuery selector methods or techniques).
 
Last edited:

ripken204

[H]ard|Gawd
Joined
Aug 24, 2007
Messages
1,427

PTNL

Supreme [H]ardness
Joined
Jan 2, 2005
Messages
4,199
What I'm trying to do:

I often see pages where I'd like to sort or arrange a number of elements, like sorting book titles on a page into alphabetical order, or sorting a random scattering of dates into chronological order, etc. I'm attempting this only as a self-assigned example on my way to learning Javascript and jQuery.
Check out DataTables.net and see if that works for you, or perhaps gives you some ideas on rolling your own.
 

Bigbacon

Fully [H]
Joined
Jul 12, 2007
Messages
20,106
unless you want to learn to do it yourself, there are plenty of jquery plugins out there that will do the work for you.
 

Coldblackice

[H]ard|Gawd
Joined
Aug 14, 2010
Messages
1,151
unless you want to learn to do it yourself, there are plenty of jquery plugins out there that will do the work for you.

Well, I was sort of looking to learn to do it myself, but I also wouldn't mind any jQuery plugin references, if you have any.
 
Top