I have a good way to sort data "naturally" with an IComparer
similar to the answers @ Natural Sort Order in C#. In my case, I have a class that goes something like this:
public class Widget
{
public int Id { get; set; }
public string Name { get; set; }
}
If I have a collection that reads as follows,
[{Id: 1, Name: "2 N. Street"},{Id: 2, Name: "33 N. Street"},{Id: 3, Name: "4 N. Street"}]
using an OData query like the following would return the data in the same order as above,
http://www.example.com/Widget.svc/GetWidgets?$orderby=Name
while I actually would like the data "naturally" ordered as such:
[{Id: 1, Name: "2 N. Street"},{Id: 3, Name: "4 N. Street"},{Id: 2, Name: "33 N. Street"}]
Is there a good way to customize a WCF service to make any query that tries to order by any string property to sort data "naturally"?