Failed Sorting

Attempted to create sort function, but javascript object don't sort and
the elements needed to sort an array won't work with the amount of data
in the object parameters correctly.