using System.Collections.Generic;
public static void Main()
Assert.AreEqual("Thi1s is2 3a T4est", Kata.Order("is2 Thi1s T4est 3a"));
Assert.AreEqual("Fo1r the2 g3ood 4of th5e pe6ople", Kata.Order("4of Fo1r pe6ople g3ood th5e the2"));
Assert.AreEqual("", Kata.Order(""));
public static string Order(string words)
if (String.IsNullOrEmpty(words))
string[] word = words.Split(' ');
string sentens = String.Empty;
Dictionary<int, string> sortedWords = new Dictionary<int, string>();
foreach (string x in word)
for (int index = 0; index < x.Length; index++)
if (Char.IsDigit(x, index))
sortedWords.Add((int)Char.GetNumericValue(x,index), x);
for (int index = 1; index < sortedWords.Count + 1; index++)
if (sortedWords.ContainsKey(index))
sentens += sortedWords[index] + " ";
return sentens.TrimEnd();