[ad_1]
You can convert string to array using split() and reverse the array element using reverse() and then convert result to string again using join() like this:
var Str="8,0,2,10";
var dif = Str.split(',').reverse().join(',');
console.log(dif);
0
[ad_2]
solved Sorting strings in javascript [duplicate]