SHARE
TWEET

Untitled

a guest Sep 15th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.     public class WeightSort
  6.     {
  7.         public static string orderWeight(string strng)
  8.         {
  9.             var weights = strng.Split(' ')
  10.                 .OrderBy(num => num.Sum(x => (int)char.GetNumericValue(x)))
  11.                 .ThenBy(num => num);
  12.  
  13.             return String.Join(" ", weights);
  14.         }
  15.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top