Friday, January 13, 2017

sort string elements in an array object

$scope.source.specializations.sort(function(a, b) {
    var textA = a.specialization.toUpperCase();
    var textB = b.specialization.toUpperCase();
    return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
});

No comments:

Post a Comment