Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sorting String Problem need help
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { string [] times = new string[] {"Ken-01:14:00", "Sal-02:06:00", "Dave-04:09:00", "Danny-11:12:01", "Mel-02:06:02" }; Array.Sort(times, TimerSort); foreach(string t in times) Console.WriteLine("Times : " + t); } static int TimerSort(string a, string b, string c){ string [] _c = c.Split('-'); string [] _a = a.Split(':'); string [] _b = b.Split(':'); int i = 0, ret = 0; for( ; i < _a.Length ; ++i){ ret = int.Parse(_a[i]).CompareTo(int.Parse(_b[i])); if(ret != 0) return ret; } return ret; } } } /* RESULT should look like this: Times: Ken-01:14:00 Times: Rio-02:06:00 Times: Dred-02:06:02 Times: Megan-04:09:00 Times: Den-11:12:01 */
run
|
edit
|
history
|
help
0
EFDS
Unsorted array with most occurence
4
Card Shuffling
Hehd
recur 4
selam
Math v9.1
Xml in C#
Array Alternate elements