Skip to content

Instantly share code, notes, and snippets.

@creyke
Created March 26, 2021 09:43
Show Gist options
  • Save creyke/25413307fe322bbbe1f2f0539eb88c33 to your computer and use it in GitHub Desktop.
Save creyke/25413307fe322bbbe1f2f0539eb88c33 to your computer and use it in GitHub Desktop.
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