← Back to Posts

json array sortByProperty

👤 علی ذوالفقار 📅 1402/10/26 21:38:44 👁️ 223 views
const sortByProperty = (prop) => {
    return function (a, b) {
        if (a[prop] > b[prop])
            return 1;
        else if (a[prop] < b[prop])
            return -1;
        return 0;
    }
};        
← Back to Posts