Created
March 26, 2021 09:43
-
-
Save creyke/25413307fe322bbbe1f2f0539eb88c33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
namespace MarketSort.Solutions | |
{ | |
class SorterF : ISorter | |
{ | |
public IEnumerable<string> Sort(IEnumerable<string> values) | |
{ | |
return values | |
.OrderBy(s => Regex.IsMatch(s, "[A-Z]")) | |
.ThenByDescending( | |
s => Regex.Replace(s, "[0-9]+", | |
s => s.Value.Split("-")[0].PadLeft(10, '0'))) | |
.Reverse(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment