I'm trying to convert and order a set of strings.
The Model:
public class PartnerSearchResultDTO
{
public int Id { get; set; }
public string Distance { get; set; }
public int Classification { get; set; }
}
Where I have for example a set:
IList<PartnerSearchResultDTO> partnersDTO = new List<PartnerSearchResultDTO>();
partnersDTO =
Id = 1 | Distance = "2,7" | Classification = 1
Id = 2 | Distance = "5" | Classification = 1
Id = 3 | Distance = "4,3" | Classification = 1
Id = 4 | Distance = "5,2" | Classification = 1
Id = 5 | Distance = "8" | Classification = 1
And I order like this:
partnersDTO = partnersDTO.ToList().OrderBy(p => double.Parse(p.Distance)).ToList();
If the Browser's language is set to Portugues "pt-PT", it order correctly:
2,7 -> 4,3 -> 5 -> 5,2 -> 8
If the Browser's language is set to English "en-us", it ignores the comma and orders like this:
5 -> 8 -> 2,7 -> 4,3 -> 5,2