.sort(direction)

Description

The sort method takes in an array as input and returns the array but sorted by its items in an order

Parameters

Direction can either be empty, "ascending" or "descending"

Usage On Arrays

arr = [5,7,2,3,1,4,6]
// setup the array

log arr.sort()
// [1,2,3,4,5,6,7]
// returns the array but sorted

Last updated