Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

how to sort numbers in typescript

var stringArray: string[] = ['AB', 'Z', 'A', 'AC'];

var sortedArray: string[] = stringArray.sort((n1,n2) => {
    if (n1 > n2) {
        return 1;
    }

    if (n1 < n2) {
        return -1;
    }

    return 0;
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #numbers #typescript
ADD COMMENT
Topic
Name
4+4 =