473,468 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Best way to sort...

I have a string array full of values like this:

05 00 0A 5E 4C 40 40
03 00 C0 9F 27 60 57
08 00 C0 9F 36 71 35
01 00 0A 5E 4E 40 13

I want to sort them in an ascending fashion based on the two left-most
numbers, such as 05, 03, 08 and 01. What is the best way I should try to do
this?
May 31 '06 #1
5 1061
Perhaps is not the best way, but is the easier way in this context:

Array.Sort(YourArray)

[]s

Cesar
"Military Smurf" <Mi***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
I have a string array full of values like this:

05 00 0A 5E 4C 40 40
03 00 C0 9F 27 60 57
08 00 C0 9F 36 71 35
01 00 0A 5E 4E 40 13

I want to sort them in an ascending fashion based on the two left-most
numbers, such as 05, 03, 08 and 01. What is the best way I should try to
do
this?

May 31 '06 #2
I should add that I have declared my array as such:

Dim MACList(23) As String

So the SORT won't work...


"ronchese" wrote:
Perhaps is not the best way, but is the easier way in this context:

Array.Sort(YourArray)

[]s

Cesar
"Military Smurf" <Mi***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
I have a string array full of values like this:

05 00 0A 5E 4C 40 40
03 00 C0 9F 27 60 57
08 00 C0 9F 36 71 35
01 00 0A 5E 4E 40 13

I want to sort them in an ascending fashion based on the two left-most
numbers, such as 05, 03, 08 and 01. What is the best way I should try to
do
this?


May 31 '06 #3
I have coded like that and worked:
Dim arr(3) As String
arr(0) = "05 00 0A 5E 4C 40 40"
arr(1) = "03 00 C0 9F 27 60 57"
arr(2) = "08 00 C0 9F 36 71 35"
arr(3) = "01 00 0A 5E 4E 40 13"
Array.Sort(arr)

I debugged that and the array was sorted.


"Military Smurf" <Mi***********@discussions.microsoft.com> wrote in message news:F8**********************************@microsof t.com...
I should add that I have declared my array as such:

Dim MACList(23) As String

So the SORT won't work...




"ronchese" wrote:
Perhaps is not the best way, but is the easier way in this context:

Array.Sort(YourArray)

[]s

Cesar


"Military Smurf" <Mi***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
>I have a string array full of values like this:
>
> 05 00 0A 5E 4C 40 40
> 03 00 C0 9F 27 60 57
> 08 00 C0 9F 36 71 35
> 01 00 0A 5E 4E 40 13
>
> I want to sort them in an ascending fashion based on the two left-most
> numbers, such as 05, 03, 08 and 01. What is the best way I should try to
> do
> this?



Jun 1 '06 #4
Maybe I should have been more clear-the sorting MAY work, but I do not know
how to retrieve the sorted values. Using your example:

MsgBox(arr(0)) doesn't display the first element, so I don't know how to get
the newly sorted values.

"ronchese" wrote:
I have coded like that and worked:
Dim arr(3) As String
arr(0) = "05 00 0A 5E 4C 40 40"
arr(1) = "03 00 C0 9F 27 60 57"
arr(2) = "08 00 C0 9F 36 71 35"
arr(3) = "01 00 0A 5E 4E 40 13"
Array.Sort(arr)

I debugged that and the array was sorted.


"Military Smurf" <Mi***********@discussions.microsoft.com> wrote in message news:F8**********************************@microsof t.com...
I should add that I have declared my array as such:

Dim MACList(23) As String

So the SORT won't work...


"ronchese" wrote:
Perhaps is not the best way, but is the easier way in this context:

Array.Sort(YourArray)

[]s

Cesar
"Military Smurf" <Mi***********@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
>I have a string array full of values like this:
>
> 05 00 0A 5E 4C 40 40
> 03 00 C0 9F 27 60 57
> 08 00 C0 9F 36 71 35
> 01 00 0A 5E 4E 40 13
>
> I want to sort them in an ascending fashion based on the two left-most
> numbers, such as 05, 03, 08 and 01. What is the best way I should try to
> do
> this?

Jun 1 '06 #5
Actually I just got it working. I must have been brain dead yesterday and
didn't know it.

Thanks


"Military Smurf" wrote:
Maybe I should have been more clear-the sorting MAY work, but I do not know
how to retrieve the sorted values. Using your example:

MsgBox(arr(0)) doesn't display the first element, so I don't know how to get
the newly sorted values.

"ronchese" wrote:
I have coded like that and worked:
Dim arr(3) As String
arr(0) = "05 00 0A 5E 4C 40 40"
arr(1) = "03 00 C0 9F 27 60 57"
arr(2) = "08 00 C0 9F 36 71 35"
arr(3) = "01 00 0A 5E 4E 40 13"
Array.Sort(arr)

I debugged that and the array was sorted.


"Military Smurf" <Mi***********@discussions.microsoft.com> wrote in message news:F8**********************************@microsof t.com...
I should add that I have declared my array as such:

Dim MACList(23) As String

So the SORT won't work...


"ronchese" wrote:

> Perhaps is not the best way, but is the easier way in this context:
>
> Array.Sort(YourArray)
>
> []s
>
> Cesar
>
>
> "Military Smurf" <Mi***********@discussions.microsoft.com> wrote in message
> news:76**********************************@microsof t.com...
> >I have a string array full of values like this:
> >
> > 05 00 0A 5E 4C 40 40
> > 03 00 C0 9F 27 60 57
> > 08 00 C0 9F 36 71 35
> > 01 00 0A 5E 4E 40 13
> >
> > I want to sort them in an ascending fashion based on the two left-most
> > numbers, such as 05, 03, 08 and 01. What is the best way I should try to
> > do
> > this?
>
>
>

Jun 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PWalker | last post by:
Hi, I have written code that I would like to optimize. I need to push it to the limit interms of speed as the accuracy of results are proportional to runtime. First off, would anyone know any...
6
by: Sean Berry | last post by:
Hello all I have build a list that contains data in the form below -- simplified for question -- myList = ,, ...] I have a function which takes value3 from the lists above and returns...
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
7
by: John 3:16 | last post by:
Hello... I have a question related to performance. Being new to asp.net & vp programming, I put together a webform that displays columns of data in a datagrid. Users can sort by the header label....
14
by: Jon Rea | last post by:
I am currently cleaning up an application which was origainlly hashed together with speed of coding in mind and therefore contains quite a few "hacky" shortcuts. As part of this "revamping"...
5
by: darthghandi | last post by:
I've created a class to listen to all interfaces and do a BeginAccept(). Once it gets a connection, it passes the connected socket off and stores it in a List. Next, it continues to listen for...
11
by: Sarath | last post by:
I'm so much font of working with C++ . That's the reason why I'm not yet looked or craze about any other language. Still a question exists, really C++ is the best language in its category?
9
by: Aaron Watters | last post by:
....is to forget they are sorted??? While trying to optimize some NUCULAR libraries I discovered that the best way to merge 2 sorted lists together into a new sorted list is to just append them...
10
by: Tammy | last post by:
Hello all, I am wondering what is the best way to declare a struct to be used in other c and c++ files. Such as for a C API that will be used by others. 1. Declaring the typedef and the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.