Skip to content

Bessere Sortierung der Spalten #6

@stvowi

Description

@stvowi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions