Bubble sort,
1 List <string> position = new List <string> (); // coordinate 2 3 List <string> text = new List <string> (); // text 4 // <summary> 5 // bubble sort 6 // </summary> 7 // <param name = "dic"> data dictionary </param> 8 private void sortDic (Dictionary <string, string> dic) 9 {10 int Flag = 1; // Flag 11 // The maximum number of entries involved in the sorting is ranked in the last 12 for (int I = 1; I <position. count; I ++) 13 {14 if (Flag = 1) 15 {16 string ls_value = string. empty; // Temporary Variable 17 string ls_key = string. empty; // Temporary Variable 18 Flag = 0; 19 // The inner loop is responsible for comparing two adjacent numbers, and sorting the largest number at the end of 20 for (int j = 0; j <position. count-I; j ++) 21 {22 // if the first number is greater than the last one, two numbers are exchanged 23 if (int. parse (position [j]. split (',') [1])> int. parse (position [j + 1]. split (',') [1]) 24 {25 ls_key = text [j + 1]; 26 ls_value = position [j + 1]; 27 28 text [j + 1] = text [j]; 29 text [j] = ls_key; 30 position [j + 1] = position [j]; 31 position [j] = ls_value; 32 Flag = 1; 33} 34} 35} 36} 37 for (int I = 0; I <position. count; I ++) 38 {39 dic. add (text [I], position [I]); 40} 41}