How To Sort An Array In Javascript Using For Loop