|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
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? Perhaps is not the best way, but is the easier way in this context:
Array.Sort(YourArray) []s Cesar Show quoteHide quote "Military Smurf" <MilitarySm***@discussions.microsoft.com> wrote in message news:76C9F873-E8F3-489D-9C5E-C12529D9448B@microsoft.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? I should add that I have declared my array as such:
Dim MACList(23) As String So the SORT won't work... Show quoteHide quote "ronchese" wrote: > Perhaps is not the best way, but is the easier way in this context: > > Array.Sort(YourArray) > > []s > > Cesar > > > "Military Smurf" <MilitarySm***@discussions.microsoft.com> wrote in message > news:76C9F873-E8F3-489D-9C5E-C12529D9448B@microsoft.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? > > > 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. Show quoteHide quote "Military Smurf" <MilitarySm***@discussions.microsoft.com> wrote in message news:F8925521-3603-4EDD-8262-482A66D60191@microsoft.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" <MilitarySm***@discussions.microsoft.com> wrote in message >> news:76C9F873-E8F3-489D-9C5E-C12529D9448B@microsoft.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? >> >> >> 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. Show quoteHide quote "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" <MilitarySm***@discussions.microsoft.com> wrote in message news:F8925521-3603-4EDD-8262-482A66D60191@microsoft.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" <MilitarySm***@discussions.microsoft.com> wrote in message > >> news:76C9F873-E8F3-489D-9C5E-C12529D9448B@microsoft.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? > >> > >> > >> Actually I just got it working. I must have been brain dead yesterday and
didn't know it. Thanks Show quoteHide quote "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" <MilitarySm***@discussions.microsoft.com> wrote in message news:F8925521-3603-4EDD-8262-482A66D60191@microsoft.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" <MilitarySm***@discussions.microsoft.com> wrote in message > > >> news:76C9F873-E8F3-489D-9C5E-C12529D9448B@microsoft.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? > > >> > > >> > > >> |
|||||||||||||||||||||||