-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsort_array_map.cpp
46 lines (29 loc) · 933 Bytes
/
sort_array_map.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
// To execute C#, please define "static void Main" on a class
// named Solution.
// C#
class Solution
{
static void Main(string[] args)
{
string[] stream = {
};
var myDic = new Dictionary<string,int>();
foreach(var s in stream){
var arr = s.Split('|');
var tags = arr[2].Split(',');
foreach(var t in tags){
if(myDic.ContainsKey(t)){
myDic[t]= myDic[t]+1;
} else {
myDic.Add(t,1);
}
}
}
//myDic.OrderBy(x=> x.Key).ThenBy(x=> x.Value);
foreach(var d in myDic.OrderBy(x=> x.Key).ThenBy(x=> x.Value)){
Console.WriteLine(d.Value.ToString() + " " + d.Key);
}
}
}