Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sort String
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", "Sol-02:06:00", "Ben-04:09:00", "Lolly-11:12:01", "Sam-02:06:02" }; Array.Sort(times, TimerSort); foreach(string t in times) Console.WriteLine("Times : " + t); } static int TimerSort(string a, string b){ string [] _a1 = a.Split(); string [] _b1 = b.Split(); string [] _a = _a1[1].Split(':'); string [] _b = _b1[1].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; } } }
run
|
edit
|
history
|
help
0
SADCAX AAAA
Overloading Unary operator ~ (to reverse the string)
Decimal separator diff
quick sort
Move 2 ushort to 1 int
Fibonacci Series
Hello world... I need cc!!
EX8 Loop_For_While
z
breadbank