Order by on String's substring in Linq -


i have date field convert value of database datetime string format("dd-mmm-yyyy"), need perform sorting string date field, seems when have been doing sorting, working , checking date, not month not year. when data in date format (database):

2012-01-29 2011-01-01 2013-03-28 

so sorted

2013-03-28 2012-01-29 2011-01-01 

but sorted: 29-jan-2012 28-mar-2013 01-jan-2011

so want apply orderbydescending-> by-> on, need split string end, there way around? doing:

list<c> lst=lst.orderbydescending(d=>d.tdate.substring(d.tdate.lastindexof('-').tolist(); 

how this,

list<string> lst= new list<string>{"29-jan-2012", "28-mar-2013", "01-jan-2011","2011-01-01","2013-03-28"}; lst.orderbydescending(x=>datetime.parse(x)); 

in sample should be,

lst.orderbydescending(x=>datetime.parse(x.tdate)) 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -