Sort Array Without Using Sort Function Javascript