javascript how to sort strings containing comma separated values

javascript how to sort strings containing comma separated values

I would like to know how can I sort strings in javascript containing comma separated values in different order e.g.

      1. Need to remove the distance "Km"
      2. Sort values comma delimited
ASC
      3. append the distances to each distance

input value "10km,50km, 21.1km"; result "50km,21.1km,10km";
Your help will be appreciated.

Thanks