public JSONProcessData(Process[] proc, int sort) { Int64 phav = PerformanceInfo.GetPhysicalAvailableMemoryInMiB(); Int64 tot = PerformanceInfo.GetTotalMemoryInMiB(); UsedMem = (uint) Math.Round(100 - (((decimal) phav / (decimal) tot) * 100)); TotalMem = (uint) tot; Processes = new JSONSingleProcessData[proc.Length]; int i = 0; foreach (Process process in proc) { Processes[i] = new JSONSingleProcessData(process); i++; } switch (sort) { case JSONProcessDataSort.SORT_BY_NAME: Array.Sort(Processes, delegate(JSONSingleProcessData proc1, JSONSingleProcessData proc2) { return proc1.Name.CompareTo(proc2.Name); }); break; case JSONProcessDataSort.SORT_BY_USAGE: Array.Sort(Processes, delegate(JSONSingleProcessData proc1, JSONSingleProcessData proc2) { return proc1.Mem.CompareTo(proc2.Mem); }); Array.Reverse(Processes); break; } }