0

[possible duplicate] How to customize sort order of strings

Regarding the same question which was stated to order this list:

bufallo@2000
lice@20
cell@1
rat@150
cow@10000

...into this list:

cow@10000
bufallo@2000
rat@150
lice@20
cell@1

Suppose I were to neglect the numeric part less than 100 - That is, to remove the other two:

cow@10000
bufallo@2000
rat@150

Is this possible? I have tried the code below, but I do not know how I can customize the numeric part less than 100 thereby deleting the rest.

Dim number As Int32 = Int32.MinValue
Dim orderedLines = From line In TextBox1.Lines
                   Let parts = line.Split("@"c)
                   Let numericPart = parts.Last()
                   Let success = Int32.TryParse(numericPart, number)
                   Select LineInfo = New With {line, number}
                   Order By LineInfo.number Descending
                   Select LineInfo.line
' if you want to reassign it to the TextBox:
TextBox1.Lines = orderedLines.ToArray()

1 Answer 1

1

My VB LINQ experience is pretty sparse, but is this what you want?

Dim orderedLines = From line In TextBox1.Lines
                   Let parts = line.Split("@"c)
                   Let numericPart = parts.Last()
                   Let success = Int32.TryParse(numericPart, number)
                   Select LineInfo = New With {line, number}
                   Where number >= 100      ' something like this?
                   Order By LineInfo.number Descending
                   Select LineInfo.line
Sign up to request clarification or add additional context in comments.

1 Comment

@user2625447 I highly doubt it's null.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.