DEV Community

loading...

Discussion on: Sorting Arrays of Strings in JavaScript

Collapse
christophdellavalle profile image
christophdellavalle

I know it is an extension of the topic... How can I add an argument to the callback-function? I want to sort Objects according to their properties.

example of not working dummy code:
var sortprop='weight';
animals.sort(function (a, b, sortprop){....});

Forem Open with the Forem app