Sort method order the value as string, it's work fine for string but if its number. sorting it will return incorrect data for the numbers. To overcome this issue we need to use compare function.
Read this post on codeasearch.com