Jump to content

Array sorting and removing


Recommended Posts

i have an array of strings and what i want to do is remove any array strings that have a length of 0 or = "" / nothing / null but i cant figure out how to do this

the other thing i want to do is a smarter array sorting method that sorts numbers

0

1

2

3

4

6

7

8

9

10

instead of

0

1

10

11

12

2

20

21

3

and so on anyone know where i could find info on this type of sorting or have the appropriate code to do so? ive been googling for ages with no luck

Edited by Cyber Axe
Link to comment
Share on other sites


Hi Cyber,

I caught your post before you edited it. I think you are looking in the wrong place to remove blank lines. instead of removing them from the array, let the sort function bring them to the top and use the trim method after rejoining the string, like this.

frmNotepad.txtNotepad.Text = String.Join(Environment.NewLine, sArray).trim

one way to do smart number sorting of strings is left pad the string to a fixed length with a known character sequence that precedes 0 in the ascii table (like *) sort the array, then go back through the array removing the pad characters.

Edited by dman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...