Home >Web Front-end >JS Tutorial >How to use Js sort_javascript skills
The parameter in array.sort() in javascript needs to be passed in a function, and it must be a function.
The x and y represent the two objects in the array.
It should be noted that there are only three return types: negative integer, zero, positive integer
It is generally customary to use -1 0 1 to represent
There is also a little trick , if you only need to compare one attribute, such as age here, then the entire sorting method is only one sentence