I have a set of rows I return from a database. They are returned in the form (media_id,order,front_image). One of the media has a front_image value of TRUE. I then have a sort function like so:
.sort(function (m1, m2) {
if (m1.order < m2.order) {
val = -1;
} else if (m1.order > m2.order) {
val = 1;
}
return val;
})
What I'm trying to achieve is to guarantee that if a media has a front_image value of TRUE, it will be the first in the array. I tried adding it as an or statement within the sortFunction but this did not produce the correct results.
true? Or is it a string"TRUE"?