Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6471639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:14:50+00:00 2026-05-25T06:14:50+00:00

How should i use linq to sort my data when my data contain both

  • 0

How should i use linq to sort my data when my data contain both numbers and letters?

For example my current linq

Dim MyQuery = From c In XDoc.Descendants() _
Where c.Attribute(Y) IsNot Nothing And c.Attribute(Str) IsNot Nothing _
Order By Val(c.Attribute(Y).Value), Val(c.Attribute(X).Value) _
Select Str = c.Attribute(Str)

returns something like the following

13
167   
172   
231      
44    
49  

which is not what i would like it to be…
The output should be like the one below

13
44    
49 
167   
172   
231      

Any ideas?
Thank you for your time

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:14:51+00:00Added an answer on May 25, 2026 at 6:14 am

    Don’t use the Value property of XAttribute – use the explicit conversion to Integer. I think this should do it:

    Dim MyQuery = From c In XDoc.Descendants() _
    Where c.Attribute(Y) IsNot Nothing And c.Attribute(Str) IsNot Nothing _
    Order By CInt(c.Attribute(Y)), CInt(c.Attribute(X)) _
    Select Str = c.Attribute(Str)
    

    Note that it’s generally a better idea to use the explicit conversions supported by XAttribute and XElement than to use Int32.Parse etc, as then the XML-specific parsing will be performed, following the appropriate standard formats.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use linq to sort a resultset. The resultset should contain all
I wonder how I should use the GTree (from GLib) to store data? Every
In performance point of view what should you use Nested foreach's or lambda/linq queries?
I know you should use POST whenever data will be modified on a public
I am just starting to use linq to sql for data access. It is
Spent all day trying to find ready to use solution for Sort data in
How can i use linq to list all pixels from image and process on
In which situations I should use LINQ to Objects? Obviously I can do everything
I use LINQ to Objects instructions on an ordered array. Which operations shouldn't I
MSDN says that you should use structs when you need lightweight objects. Are there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.