Sorting 1st, 2nd, 3rd...

M

mphell0

I have a list of streets that I want to put in ascending order. Some o
the streets are named 1st, 2nd etc and others are just names. When I d
a sort on the data it correctly puts the named streets in order bu
numbered streets appear out of order

for example

10th
11th
1st
20th
21st
2nd
30th
31st
3rd
a
b
c

Is there an easy way to sort so that it recognizes 1st and 2nd... i
the correct order so that it would sort like this:

1st
2nd
3rd
10th
11th
etc.

Any help would be appreciated
 
R

Ron Rosenfeld

I have a list of streets that I want to put in ascending order. Some of
the streets are named 1st, 2nd etc and others are just names. When I do
a sort on the data it correctly puts the named streets in order but
numbered streets appear out of order

for example

10th
11th
1st
20th
21st
2nd
30th
31st
3rd
a
b
c

Is there an easy way to sort so that it recognizes 1st and 2nd... in
the correct order so that it would sort like this:

1st
2nd
3rd
10th
11th
etc.

Any help would be appreciated.

Use a "helper column" into which you extract only the numeric portion. Then
sort on that "helper column".

Assuming a maximum of three digits in the number portion, one formula that will
extract the digits is:

=LEFT(A1,MATCH(FALSE,ISNUMBER(-LEFT(A1,{1,2,3})),0)-1)

(If there could be more than three, just change the array constant
accordingly).

In later versions of Excel, there is an option to "sort anything that looks
like a number, as a number". Select that option. If that is not present, then
use this similar formula, which will converts the "text" number to a "real"
number:

=IF(ISNUMBER(-LEFT(A1,1)),--LEFT(A1,MATCH(
FALSE,ISNUMBER(-LEFT(A1,{1,2,3})),0)-1),"")



--ron
 
M

mphell0

Thanks Ron but I found an easy way to do it without using helpe
columns.
Maybe this will help others in the future. In Tools>Options>Custo
Lists
you can create a list of values and how you want them sorted. I pu
in
1st, 2nd, 3rd etc. into this list. Then when I went to do my sort, i
the sort
menu there is a tab called "options" that allows you to select a custo
list to
define the sort order. This worked perfectly
 
R

Ron Rosenfeld

Thanks Ron but I found an easy way to do it without using helper
columns.
Maybe this will help others in the future. In Tools>Options>Custom
Lists
you can create a list of values and how you want them sorted. I put
in
1st, 2nd, 3rd etc. into this list. Then when I went to do my sort, in
the sort
menu there is a tab called "options" that allows you to select a custom
list to
define the sort order. This worked perfectly.

I'm glad that worked for you. Of course, you need to have all the items in the
list, or it may not sort properly. Also, I'm not sure (you should check it if
it may be an issue), if custom lists are stored with the workbook. That could
be an issue if you move the workbook to another machine.
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top