I am trying to sort the items in alphbatical order. However, I also want to sort item type as well.
For example:
I want
type sortValue
blockItem a test1
blockItem a test2
blockItem b test3
imageItem a image
imageItem b image
imageItem c image
imageItem s image
textItem a text
textItem b text
textItem c text
My code would do things like this.
type sortValue
blockItem a test1
blockItem a test2
imageItem a image
textItem a text
blockItem b test3
imageItem b image
textItem b text
imageItem c image
textItem c text
imageItem s image
my sort function
array contains type and sortvalue
array=array.sort(sortFunction);
function sortFunction(groupA, groupB) {
if (groupA.sortValue > groupB.sortValue) {
return 1;
} else if (groupA.sortValue < groupB.sortValue) {
return -1;
}
return 0;
}
It only sort the text but not the type. I was wondering if there are anyways to do this. Thanks so much!