DEV Community


Discussion on: Sorting Arrays of Strings in JavaScript

christophdellavalle profile image

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