How can I sort a CollectionViewSource by a numeric string value.<p>i have a collection view source which is populated with invoice items.<br/><br/>Each invoice item contains an invoice reference which is stored in the database as a varchar, although it is a numeric value.<br/><br/>I am using Linq to return my objects from the database and a converter to bind everything to the CVS.  I need to sort by the invoice reference but it is sorting as string <br/><br/>(ie. 1, 100, 2, 200, 3, 300)<br/><br/>How can I apply a converter to the the sort parameter before if performs the sort?</p>© 2009 Microsoft Corporation. All rights reserved.Thu, 09 Jul 2009 14:57:07 Zad99d6b6-6885-4167-a78d-cffa7084c9b0http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#ad99d6b6-6885-4167-a78d-cffa7084c9b0http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#ad99d6b6-6885-4167-a78d-cffa7084c9b0Jeffrey Cumpstyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Jeffrey%20CumpstyHow can I sort a CollectionViewSource by a numeric string value.<p>i have a collection view source which is populated with invoice items.<br/><br/>Each invoice item contains an invoice reference which is stored in the database as a varchar, although it is a numeric value.<br/><br/>I am using Linq to return my objects from the database and a converter to bind everything to the CVS.  I need to sort by the invoice reference but it is sorting as string <br/><br/>(ie. 1, 100, 2, 200, 3, 300)<br/><br/>How can I apply a converter to the the sort parameter before if performs the sort?</p>Sat, 04 Jul 2009 15:49:15 Z2009-07-04T15:49:15Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#b31378d9-5d2d-4eab-8cea-4301a7179986http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#b31378d9-5d2d-4eab-8cea-4301a7179986Mariano O. Rodriguezhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mariano%20O.%20RodriguezHow can I sort a CollectionViewSource by a numeric string value.You'd better convert the invoice number in the LINQ query, you can solve this in the CollectionView sorting.<hr class="sig">http://weblogs.asp.net/marianor/Sat, 04 Jul 2009 17:54:00 Z2009-07-04T17:54:00Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#fea4a97b-cbfb-4b02-b665-811c15029d9bhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#fea4a97b-cbfb-4b02-b665-811c15029d9bJeffrey Cumpstyhttp://social.msdn.microsoft.com/Profile/en-US/?user=Jeffrey%20CumpstyHow can I sort a CollectionViewSource by a numeric string value.<blockquote>You'd better convert the invoice number in the LINQ query, you can solve this in the CollectionView sorting. <hr class=sig> http://weblogs.asp.net/marianor/</blockquote> <br/>Please Clarify....Did you mean to type &quot;CAN'T solve this in the Collectionview sorting&quot;?<br/><br/><br/><br/>As a workaround I have added an &quot;InvoiceNumberInt&quot; property to my Invoice.  Perhaps this is the best way to do it in the long run.  One of the things I like about the entity framework is that everything is a partial class so it makes is very easy to add methods and properties that I need.<br/><br/>Cheers.Sat, 04 Jul 2009 18:14:17 Z2009-07-04T18:14:17Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#a7c20189-ece4-4496-a758-aee3e2b74b8ahttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#a7c20189-ece4-4496-a758-aee3e2b74b8aMariano O. Rodriguezhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mariano%20O.%20RodriguezHow can I sort a CollectionViewSource by a numeric string value.<p>SortDescription class only receives the name of the property and sort direction, there is not any way to add custom logic to apply a converter to order in a different way.</p><hr class="sig">http://weblogs.asp.net/marianor/Sat, 04 Jul 2009 18:22:17 Z2009-07-04T18:22:17Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#bd673926-6ff5-4a8c-b0db-961c5acddbbdhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ad99d6b6-6885-4167-a78d-cffa7084c9b0#bd673926-6ff5-4a8c-b0db-961c5acddbbdTedhttp://social.msdn.microsoft.com/Profile/en-US/?user=TedHow can I sort a CollectionViewSource by a numeric string value.Have a look at the CustomSort property, that is if your collectionview is a ListCollectionView: <div>http://msdn.microsoft.com/en-us/library/system.windows.data.listcollectionview.customsort.aspx</div> <div><br/></div>Sat, 04 Jul 2009 19:16:03 Z2009-07-04T19:16:03Z