// sort the letters in the list // TODO : change it in order to sort by frequency or letter position public static void Sort() { List <int> valueList = new List <int>(); List <analiticValue> output = new List <analiticValue>(); foreach (analiticValue value in values) { valueList.Add(value.frequency); } valueList.Sort(); int[] valueInt = valueList.ToArray(); valueList = null; for (int i = 0; i < valueInt.Length; i++) { analiticValue letterFoudnd = getLetter(valueInt[i]); if (letterFoudnd != null) { output.Add(letterFoudnd); } } values = output; }
//analize the frequency of the letters public static analiticValue[] analizeFrequency(string input) { int totalLetters = 0; foreach (char letter in input) { totalLetters++; int pos = analiticsValues.valueExist(letter); if (pos != -1) { analiticsValues.values[pos].frequency += 1; } else { analiticValue newLetter = new analiticValue(letter); newLetter.frequency = 1; analiticsValues.Add(newLetter); } } analiticsValues.Sort(); return(analiticsValues.values.ToArray()); }
// add the value public static void Add(analiticValue val) { values.Add(val); }