Languages
[Edit]
EN

TypeScript - sort array

0 points
Created by:
James-Z
767

1. Overview

Edit

In TypeScript it is possible to sort array in following ways.

2. Sorting array in ascending ordering

Edit

In this example numbers are sorted from smallest to biggest - Array sort (Array.prototype.sort) method with ascending ordering has been used.

Output:

3. Sorting array in ascending ordering with compare function

Edit

In this example numbers are sorted from smallest to biggest with compare function.

Output:

4. Sorting array in desscending ordering with compare function

Edit

In this example numbers are sorted from biggest to smallest - in this case compare function is necessary.

Output:

5. Sorting array in desscending ordering with reverse method example

Edit

In this example numbers are sorted from biggest to smallest - in this case reverse function has been used.

Output:

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join