Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class WeightSort
- {
- public static string orderWeight(string strng)
- {
- var weights = strng.Split(' ')
- .OrderBy(num => num.Sum(x => (int)char.GetNumericValue(x)))
- .ThenBy(num => num);
- return String.Join(" ", weights);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement