javascript to sort items