Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bessere Sortierung der Spalten #6

Open
stvowi opened this issue Nov 27, 2015 · 0 comments
Open

Bessere Sortierung der Spalten #6

stvowi opened this issue Nov 27, 2015 · 0 comments

Comments

@stvowi
Copy link

stvowi commented Nov 27, 2015

Spalten mit numerischen Werten werden falsch sortiert. Ich bitte um eine zeitnahe Lösung des Problems!

Es sollte die Möglichkeit bestehen, über eine CSS-Klasse ('sort-default', 'sort-numeric', 'sort-auto', 'sort-date', 'sort-datetime', 'sort-time')
im TH-Tag einer Spalte den Comperator für das Plugin "sortElements" zu definieren.

Bitte lesen Sie als Inspiration den Beitrag von Dan G. Switzer, II (http://james.padolsey.com/javascript/sorting-elements-with-jquery/):

The only thing I might change would be to have the comparator argument default to a generic sort algorithm and maybe to even allow a string
for some built-in handy sort goodness:

"default" = function(a, b){
    return $(a).text() > $(b).text() ? 1 : -1;
}

"numeric" = function(a, b){
    return parseInt($(a).text(), 10) > parseInt($(b).text(), 10) ? 1 : -1;
}

"auto" = function(a, b){
    a = $(a).text();
    b = $(b).text();

    return (
        isNaN(a) || isNaN(b) ?
        a > b : +a > +b
    ) ?
        inverse ? -1 : 1 :
        inverse ? 1 : -1;
}

It would add a little to the code, but could save you from a lot of re-implementation of the same sorting algorithms
(since the odds are most implementations are going to come down to the same core algorithms.)

Comperatoren für Date-, Date/Time-, Time-Werte wären auch wünschenswert, wobei die länderspezifische Schreibweise zu berücksichtigen ist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant