Merge pull request #335 from Jiiniasu/NameSelection-sorted

Sort Profiles by Player Name
This commit is contained in:
Florian Küpper authored and GitHub committed 2017-11-13 10:56:55 +01:00
commit 9e0f715fce
1 file changed
+9 -3
+9 -3
View File
@@ -19,6 +19,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using VocaluxeLib;
using VocaluxeLib.Draw;
using VocaluxeLib.Profile;
@@ -300,7 +301,7 @@ namespace Vocaluxe.Base
return new CProfile[0];
var list = new List<CProfile>(_Profiles.Values);
list.Sort(_CompareByPlayerName);
list.Sort(_AlphaNumericCompareByPlayerName);
return list.ToArray();
}
@@ -646,9 +647,14 @@ namespace Vocaluxe.Base
_ProfilesChanged = true;
}
private static int _CompareByPlayerName(CProfile a, CProfile b)
private static int _AlphaNumericCompareByPlayerName(CProfile a, CProfile b)
{
return String.CompareOrdinal(a.PlayerName, b.PlayerName);
return _PadNumbersInString(a.PlayerName).CompareTo(_PadNumbersInString(b.PlayerName));
}
private static string _PadNumbersInString(string text)
{
return Regex.Replace(text, "[0-9]+", match => match.Value.PadLeft(4, '0'));
}
public static CAvatar GetAvatarByFilename(string fileName)