Sort Array In Javascript Without Sort Function In R