c# - Order the lines in a file by the last character on the line -


can please me this: want build method in c# order lot of files following rule every line contains strings , last character in every line int. want order lines in file last character, int.

thanks

to order ascending last character, interpreted integer do:

var orderedlines= file.readalllines(@"test.txt")                         .orderby(line => convert.toint32(line[line.length-1]))                         .tolist(); 

edit:

with clarification in comment - integer following space character, can more 1 digit:

var orderedlines= file.readalllines(@"test.txt")                       .orderby(line => convert.toint32(line.substring(line.lastindexof(" ")+1,                                                                          line.length - line.lastindexof(" ")-1)))                       .tolist(); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -