custom column sort for time left string

I’d like to be able to do a custom sort on a column in a grid that contains a time left string. A few string examples:

1d 20h 7m
3d 14h 17m
7h 10m
15m

If there are not days or hours, it does not print them so I’d like to be able to sort accordingly.

Also, if there is a way to use SetDateFormat to achieve the same result, please let me know.

Any help would be great.

Thanks!

Something similar to the next

grid.setCustomSorting(function(a,b, ord){ ord = (ord == "asc")?1:-1; a = a.split(" "); b = b.split(" "); var result = 0; if (a.length = b.length) { // here we need to compare elements of a and b array } else result = a.length>b.length ? 1 : -1; return result * ord; }, INDEX);