refactored code to use StandardLib.sortOn()
working around Array.sort(Array.NUMERIC) crash when there is an
undefined value.

Change-Id: I6416759410aa7cd19e83e36e11f41648667a199c