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
ref variables/parameters
Comp4.1
dateTime parsing
Example of dates in c#, Ejemplo de fechas en c#
Uri builder
SHA Tester 2.1
ArithmeticOperations
tax cal
4.3 Static typing: benefits, drawbacks and ways to minimise them
aa