Sjeiti / TinySort

TinySort is a small script that sorts HTML elements. It sorts by text- or attribute value, or by that of one of it's children.
http://tinysort.sjeiti.com/
MIT License
455 stars 68 forks source link

Is it possible to sort from the second character? #167

Closed MrzAOK closed 4 years ago

MrzAOK commented 4 years ago

Hi, is it possible to sort starting from the 2nd letter or character in a list? For example, I want to ignore the letters in bold below:

so the correct working order would be:

Sjeiti commented 4 years ago

You can sort by data attribute if you write your elements like this: <li data-sort="bat">YBat</li>.

Or you could use a custom sort function.

MrzAOK commented 4 years ago

What about if I don't have access to edit the markup? Currently I'm hiding the first letter with CSS, but I'd still like it to sort.

Sjeiti commented 4 years ago

Your only option is a custom sort function then. But if you're going to do that for all your sorts you might as well ditch TinySort and just write it yourself. It's not that hard: https://codesandbox.io/s/simplevanillaasc-decsort-6jihj