Iterate SortedDictionary keys in order.
Ready — edit the code above and click Run.
using System;
class Program
{
static void Main()
{
using System.Collections.Generic;
var map = new SortedDictionary<string, int> { ["b"] = 2, ["a"] = 1 };
Console.WriteLine(string.Join(",", map.Keys));
}
}
Try solving on your own first, then reveal the official answer.
SortedDictionary keeps keys sorted—O(log n) operations.