var genius_data = ["5,3,30,'dddd'", "6,4,21,'erq'", "1,2,20,'absd'"]; genius_data.sort(function(a, b) { return +(a.split(',')[1]) - +(b.split(',')[1]); }); alert(genius_data);