![]() |
VOOZH | about |
The sortDesc() method is used to sort the collection in the opposite order as the sort method.
Syntax:
collect.sortDesc()
Parameters: The collect() method takes one argument that is converted into the collection and then sortDesc() method is applied on it.
Return Value: This method returns the collection in descending order.
The below example illustrates the sortDesc() method in collect.js:
Example 1:
Output:
[11, 8, 7, 6, 5, 4, 3]
Example 2:
Output:
[
{
subject: 'science',
score: 90,
},
{
subject: 'English',
score: 95,
},
{
subject: 'math',
score: 86,
}
]