Created
February 24, 2017 13:26
-
-
Save cschuff/3382895b8ea2b39df5a40a5d575b7f44 to your computer and use it in GitHub Desktop.
Sort Comparators for sap.ui.model.Sorter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ISO Date as string | |
function (a, b) { | |
var valA = a.split("T")[0]; | |
var valB = b.split("T")[0]; | |
if (valA < valB) return -1; | |
if (valA > valB) return 1; | |
return 0; | |
}; | |
// string as number | |
function (a, b) { | |
var valA = parseInt(a, 10); | |
var valB = parseInt(b, 10); | |
if (isNaN(valA)) return 1; | |
if (isNaN(valB)) return -1; | |
if (isNaN(valA) && isNaN(valB)) return 0; | |
return valA - valB; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment