0

So I have this so far:

JSFIDDLE

And I for the life of me cannot figure out why the price will not sort correctly? You will see that "6" appears at the end rather than the start.

Alphabetically works but no clue why price has issues.

4

5 に答える 5

2

It's because your sort function doesn't know that you want to treat $6 as "6" so it's treating it like a string and sorting it that way. This is crude, but will put you on the right track:

http://jsfiddle.net/De8Ku/1472/

于 2012-09-04T04:10:23.583 に答える
2

There seems to be a problem when sorting because of the parsing problem due the the dollar sign. I modified your code like this and it worked

var vA = parseInt($(keySelector, a).text().replace("$",''));
        var vB = parseInt($(keySelector, b).text().replace("$",''));

Try this fiddle

于 2012-09-04T04:11:25.003 に答える
1

価格をアルファスタイルに分類しているので期待されています。

このフィドルを確認してください、私はこれにソートタイプを関連付けました

http://jsfiddle.net/De8Ku/1476/

于 2012-09-04T04:15:39.287 に答える
1

This one time I had to create a table sorter plugin in jQuery, and I had to go through the same problem you have now. To be honest, I don't really remember how I solved that problem anymore, but I still have a fiddle of the code i finally used for my website if you're interested.

http://jsfiddle.net/bcnobel/WbWDm/

于 2012-09-04T04:03:10.877 に答える
1

http://jsfiddle.net/De8Ku/1479/

于 2012-09-04T04:39:19.930 に答える