I am trying to sort a xml using linq queries using the following code
Dim SortedFields = From field In feedXML.Descendants("fields")
Dim sFieldList = From field In SortedFields.Descendants("field") Order By field.@position
The xml is shown below, but the issue is it is ordering it in the following order 1,10,11,12,13,14...19,2,3,4,5,6,7 instead of 1,2,3,4,5....10,11,12,.....19.
Can anybody help me sorting it in the correct order?
<fields>
<field position="'6'" tablename="Students" headername="6" fieldreference="ClientField1" orderbydirection="ASC" displaycolumn="T" />
<field position="'7'" tablename="Students" headername="7" fieldreference="ClientField2" orderbydirection="ASC" displaycolumn="T" />
<field position="'8'" tablename="Students" headername="8" fieldreference="ClientField3" orderbydirection="ASC" displaycolumn="T" />
<field position="'9'" tablename="Students" headername="9" fieldreference="ClientField4" orderbydirection="ASC" displaycolumn="T" />
<field position="'10'" tablename="Students" headername="10" fieldreference="ClientField5" orderbydirection="ASC" displaycolumn="T" />
<field position="'1'" tablename="Students" headername="1" fieldreference="ClientField6" orderbydirection="ASC" displaycolumn="T" />
<field position="'2'" tablename="Students" headername="2" fieldreference="ClientField7" orderbydirection="ASC" displaycolumn="T" />
<field position="'3'" tablename="Students" headername="3" fieldreference="ClientField8" orderbydirection="ASC" displaycolumn="T" />
<field position="'4'" tablename="Students" headername="4" fieldreference="ClientField9" orderbydirection="ASC" displaycolumn="T" />
<field position="'5'" tablename="Students" headername="5" fieldreference="ClientField10" orderbydirection="ASC" displaycolumn="T" />
<field position="'11'" tablename="Students" headername="11" fieldreference="ClientField11" orderbydirection="ASC" displaycolumn="T" />
<field position="'12'" tablename="Students" headername="12" fieldreference="ClientField12" orderbydirection="ASC" displaycolumn="T" />
<field position="'13'" tablename="Students" headername="13" fieldreference="ClientField13" orderbydirection="ASC" displaycolumn="T" />
<field position="'14'" tablename="Students" headername="14" fieldreference="ClientField14" orderbydirection="ASC" displaycolumn="T" />
<field position="'15'" tablename="Students" headername="15" fieldreference="ClientField15" orderbydirection="ASC" displaycolumn="T" />
<field position="'16'" tablename="Students" headername="16" fieldreference="ClientField16" orderbydirection="ASC" displaycolumn="T" />
<field position="'17'" tablename="Students" headername="17" fieldreference="ClientField17" orderbydirection="ASC" displaycolumn="T" />
<field position="'18'" tablename="Students" headername="18" fieldreference="ClientField18" orderbydirection="ASC" displaycolumn="T" />
<field position="'19'" tablename="Students" headername="19" fieldreference="ClientField19" orderbydirection="ASC" displaycolumn="T" />
</fields>