473,466 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Text Sort

I have a list of IP addresses, amongst other fields in a db that I
need to sort, however, I am having difficulties accomplishing that,
and any help will be appreciated. Here is a sample list of the
entries.

It is now
10.100.1.10
10.100.1.23
10.100.1.249
10.100.1.7
10.105.1.1
10.105.1.2
10.105.1.251
10.105.1.3
10.105.1.5
10.105.1.6

It should be;
10.100.1.7
10.100.1.10
10.100.1.23
10.100.1.249
10.105.1.1
10.105.1.2
10.105.1.3
10.105.1.5
10.105.1.6
10.105.1.251

Thanks for any imput.

A. Respecte
Nov 13 '05 #1
3 2343
Consider using 4 separate fields to store the IP addresses.
Number type, size Byte.

Easy to concatenate them with dots for display purposes (e.g. on a report.)

I think that will be much more efficient than:
ORDER BY IIf([MyField] Is Null, Null, Val(Split([MyField], ".")(0)),
Val(Split([MyField], ".")(1)), Val(Split([MyField], ".")(2)),
Val(Split([MyField], ".")(3)))

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"A. Respecte" <re******@yahoo.com> wrote in message
news:58**************************@posting.google.c om...
I have a list of IP addresses, amongst other fields in a db that I
need to sort, however, I am having difficulties accomplishing that,
and any help will be appreciated. Here is a sample list of the
entries.

It is now
10.100.1.10
10.100.1.23
10.100.1.249
10.100.1.7
10.105.1.1
10.105.1.2
10.105.1.251
10.105.1.3
10.105.1.5
10.105.1.6

It should be;
10.100.1.7
10.100.1.10
10.100.1.23
10.100.1.249
10.105.1.1
10.105.1.2
10.105.1.3
10.105.1.5
10.105.1.6
10.105.1.251

Thanks for any imput.

A. Respecte

Nov 13 '05 #2
Can't guarantee it will work, but OK on sample data

Assume input table is table 1 and the IP addresses are in a field called
"Input"
Create Query 1

SELECT Table1.Input, InStr([Input],".") AS PosFirst,
CInt(Left([Input],InStr([Input],".")-1)) AS [First],
Right([Input],Len([Input])-Len([First])-1) AS Field2,
CInt(Left([Field2],InStr([Field2],".")-1)) AS [Second],
Right([Field2],Len([Field2])-Len([Second])-1) AS Field3,
CInt(Left([Field3],InStr([Field3],".")-1)) AS Third,
CInt(Right([Field3],Len([Field3])-Len([Third])-1)) AS Forth
FROM Table1;
Create Query 2

SELECT Query1.First, Query1.Second, Query1.Third, Query1.Forth,
CStr([First]) & "." & CStr([Second]) & "." & CStr([Third]) & "." &
CStr([Forth]) AS [Output]
FROM Query1
ORDER BY Query1.First, Query1.Second, Query1.Third, Query1.Forth;

HTH

Phil
"A. Respecte" <re******@yahoo.com> wrote in message
news:58**************************@posting.google.c om...
I have a list of IP addresses, amongst other fields in a db that I
need to sort, however, I am having difficulties accomplishing that,
and any help will be appreciated. Here is a sample list of the
entries.

It is now
10.100.1.10
10.100.1.23
10.100.1.249
10.100.1.7
10.105.1.1
10.105.1.2
10.105.1.251
10.105.1.3
10.105.1.5
10.105.1.6

It should be;
10.100.1.7
10.100.1.10
10.100.1.23
10.100.1.249
10.105.1.1
10.105.1.2
10.105.1.3
10.105.1.5
10.105.1.6
10.105.1.251

Thanks for any imput.

A. Respecte

Nov 13 '05 #3
Thanks Phil and Allen for both of your input. I tried both, but due
to the no of records in the database, and ease of maintenance, Phil's
query solution worked better and easier. I have been able to generate
the reports I need based on it. Again thanks for the fast responses.
-A. Respecte

"Phil Stanton" <di********@stantonfamily.co.uk> wrote in message news:<41***********************@mercury.nildram.ne t>...
Can't guarantee it will work, but OK on sample data

Assume input table is table 1 and the IP addresses are in a field called
"Input"
Create Query 1

SELECT Table1.Input, InStr([Input],".") AS PosFirst,
CInt(Left([Input],InStr([Input],".")-1)) AS [First],
Right([Input],Len([Input])-Len([First])-1) AS Field2,
CInt(Left([Field2],InStr([Field2],".")-1)) AS [Second],
Right([Field2],Len([Field2])-Len([Second])-1) AS Field3,
CInt(Left([Field3],InStr([Field3],".")-1)) AS Third,
CInt(Right([Field3],Len([Field3])-Len([Third])-1)) AS Forth
FROM Table1;
Create Query 2

SELECT Query1.First, Query1.Second, Query1.Third, Query1.Forth,
CStr([First]) & "." & CStr([Second]) & "." & CStr([Third]) & "." &
CStr([Forth]) AS [Output]
FROM Query1
ORDER BY Query1.First, Query1.Second, Query1.Third, Query1.Forth;

HTH

Phil
"A. Respecte" <re******@yahoo.com> wrote in message
news:58**************************@posting.google.c om...
I have a list of IP addresses, amongst other fields in a db that I
need to sort, however, I am having difficulties accomplishing that,
and any help will be appreciated. Here is a sample list of the
entries.

It is now
10.100.1.10
10.100.1.23
10.100.1.249
10.100.1.7
10.105.1.1
10.105.1.2
10.105.1.251
10.105.1.3
10.105.1.5
10.105.1.6

It should be;
10.100.1.7
10.100.1.10
10.100.1.23
10.100.1.249
10.105.1.1
10.105.1.2
10.105.1.3
10.105.1.5
10.105.1.6
10.105.1.251

Thanks for any imput.

A. Respecte

Nov 13 '05 #4

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

Similar topics

2
by: Mathias Mamsch | last post by:
Hi, I got a text with about 1 million words where I want to count words and put them sorted to a list like " list = " I think there are at about 10% (about 100.000) different words in the...
7
by: Sam Lowry | last post by:
Greetings. I am trying to do something which should elementary for Perl, but I have only been able to find bits and pieces on it. When I put the bits together they do not work. Maybe I am going...
4
by: Deborah V. Gardner | last post by:
I have a field with values like this CO 03-10 CO 03-4 VI 03-8 CO 03-533 I would like these to sort for a report by the first two letters and the digits after the hyphen (-) like this
4
by: Robert Hooker | last post by:
Hi all, I'm looking for a way to sort/order the Category text items in a property grid. The grids sort the categories by alpha when the catergories are displayed. Does anyone at Microsoft (or...
60
by: Julie | last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB) for a given string. The files are unindexed and unsorted, and for the purposes of my immediate requirements, can't...
3
by: Frustrated Developer via DotNetMonster.com | last post by:
I have posted a couple times on here already and found the user community to be very helpful. I took on a project before I realized how difficult a time I'm having working with a database....
4
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
2
by: BartlebyScrivener | last post by:
Hello, I'm sure this is my fault or some Windows snafu. But using gvim 7.0 on Windows XP, I can't seem to get gvim to successfully filter text through a Python script. I also use NoteTab and...
0
by: JosAH | last post by:
Greetings, Introduction At the end of the last Compiler article part I stated that I wanted to write about text processing. I had no idea what exactly to talk about; until my wife commanded...
1
by: Redbeard | last post by:
I have a text field that I used to store the unique number of each record. I wish to sort this number but since it is in a text field it will not sort numerically. I have the number in a text field...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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?

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.