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

Feature request to switch it to case-insensitive #26

Closed
oztek22 opened this issue Aug 13, 2017 · 1 comment
Closed

Feature request to switch it to case-insensitive #26

oztek22 opened this issue Aug 13, 2017 · 1 comment
Milestone

Comments

@oztek22
Copy link

oztek22 commented Aug 13, 2017

No description provided.

@ghc20
Copy link

ghc20 commented Aug 24, 2017

I modified ngx-order.pipe.ts to handle the case sensitivity issue for sorting string:

private sortArray(value: any[], expression?: any, reverse?: boolean): any[] {
    const isDeepLink = expression && expression.indexOf('.') !== -1;

    if (isDeepLink) {
        expression = OrderPipe.parseExpression(expression);
    }

    let array: any[] = value.sort((a: any, b: any): number => {
        if (!expression) {
            return a > b ? 1 : -1;
        }

        if (!isDeepLink) {
            let aVal = a[expression], bVal = b[expression];
            if (typeof aVal === 'string') {
                aVal = aVal.toLowerCase();
            }

            if (typeof bVal === 'string') {
                bVal = bVal.toLowerCase();
            }

            return aVal > bVal ? 1 : -1;
        }

        return OrderPipe.getValue(a, expression) > OrderPipe.getValue(b, expression) ? 1 : -1;
    });

    if (reverse) {
        return array.reverse();
    }

    return array;
}

@VadimDez VadimDez added this to the 1.0.4 milestone Nov 1, 2017
@VadimDez VadimDez closed this as completed Nov 1, 2017
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

3 participants