Sorting elements with JavaScript

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Sorting elements with JavaScript

Post by agibsonsw »

Yes, pleased to report my version is significantly faster - and I can sort anything, not just tables.

the 'sorttable' version does, however, attempt to determine the column data type (although it failed to recognise my date format). I'm pondering how to do this myself.

It also adds something to the class name to indicate that the list is already sorted. I use the every() method to quickly check if it's in ascending order. This is better for me as I might be changing the DOM structure with code.

I think it should also make use of a document fragment when appending the child rows - this can have a significant impact.

When did I begin to think I was an expert :scratch:

Mine's also 40-odd lines of code rather than 500 :grin:
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.