sorting - jQuery TinySort mixed literal and numeral not working -


trying sort comments on metafilter favorites. doing using tinysort , grabbing title attribute in favorites' link:

$('div.comments').tsort('span.smallcopy>span>span>a',{attr:'title',order:'desc'}); 

but mixed literal , numeral not working correctly i'm getting (5, 58, 4, 3, 39, 32, 2...) ex: http://i.imgur.com/7n1ln.jpg

instead of (58, 39, 32, 5, 4, 3, 2...)

i using latest tinysort version 1.3.27

i have tried removing space title attribute, no luck:

$('span.smallcopy>span>span>a').attr('title', function() {     return this.title.replace(/\s/g, '');  }); 

hmmm... sounds bug i'll have tomorrow afternoon , update source if indeed bug.

-edit-

the @title string, since says '4 people marked favorite'. sort technically correct.

if have been number tinysort have parsed such , sorted differently.

so solution here first use jquery set attribute using title , sort on that. instance:

$('span.smallcopy').find('a:last').each(function(i,el){     var el=$(this);     el.attr('data-favorites',parseint(el.attr('title'))); }); 

and sort. haven't tried yet maybe should http://tinysort.sjeiti.com/#returnonlysorted because source looks rather messy (br right after div :-/ )


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -