linqtosql order by string with numbers

Hi ,
Thanks !
Am using linqtosql and C#.

Have attached the screen shot of the datasource .
I need to order the list by name,  (Screen shot is attached ) but name is alphanumeric string. Each record under name starts with section ??:  i.e. Section 12 : test
                          Section 11: test
                          Section 00: test


I need to order by name by sort through numbers which you see  within the string


Expected output:
=============
{Folderkey=27, Name="Section1:Underwriting"}
{Folderkey=25, Name="Section2:Third-Parth Reports"}
{Folderkey=4, Name="Section3:Borrower"}

code:
public ActionResult FolderRearrangePopupLoad(Guid taskInstanceId, string Model)
        {
            var nums = "0123456789".ToCharArray();//skumar:20180104 for task#
            var reordermodel = new FileReorderModel { TaskInstanceId = taskInstanceId };

            var FileList = (from filelist in taskManager.GetAllTaskFileByTaskInstanceId(taskInstanceId)
                            select new
                            {
                                filelist.TaskFileId,
                                Name = filelist.FileName

                            });

            ViewBag.FileList = FileList;


            var folderlist = (from folders in appProcessManager.GetFolderbyViewId(1)
                              orderby folders.FolderName.LastIndexOfAny(nums)
                              orderby folders.FolderName
                              select new
                              {
                                  folders.FolderKey,
                                  Name = folders.FolderName

                              });
            ViewBag.FromFolder = new SelectList(folderlist, "FolderKey", "Name");

Open in new window


Kind regards,
Suresh
Folder-list.PNG
poojasureshkumarAsked:
Who is Participating?
 
poojasureshkumarAuthor Commented:
hi LVL 12,
Please find the solution from this link
https://stackoverflow.com/questions/30987026/orderby-containing-numbers-and-letters

Kind regards,
Pooja
0
 
poojasureshkumarAuthor Commented:
Hi,
Please find the screen shot. don't know why 00 is coming after 9 instead that appears at the top.

Kind regards,
Pooja
test1.PNG
0
 
poojasureshkumarAuthor Commented:
I got the solution. I would like to close the question
Please let me know if i need to improve in asking questions or what should i add on top on original question to make it more clear. Just curious why i am not getting any response for several questions.
0
 
louisfrCommented:
I cannot speak for others, but in my case, I didn't answer because you asked the question at the end of my workday yesterday and it's now the start of my next workday.

Could you post your solution ? It can help other people trying to do the same thing.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.