# Sort data in Excel

Hi I want to sort the data. and I got group 1 after I sorted it, but I hope to get it like group 2. Anyone can give me some suggestion ?

Group1:
GigabitEthernet1/1
GigabitEthernet1/10
GigabitEthernet1/11
GigabitEthernet1/18
GigabitEthernet1/19
GigabitEthernet1/2

Group2
GigabitEthernet1/1
GigabitEthernet1/2
GigabitEthernet1/10
GigabitEthernet1/11
GigabitEthernet1/18
GigabitEthernet1/19
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
If you just need to sort off of the last numbers, you can use this formula to convert them from text. Change A1 to your reference cell. Sort on this column:

=VALUE(MID(A1,FIND("/",A1)+1,LEN(A1)-FIND("/",A1,1)))

Flyster

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

And if you wana sort values before "/" then put this formula in say column B and Mr.Flyster formula in column C, so you can sort both ways.
``````=SUMPRODUCT(MID(0&(LEFT(A1,(LEN(A1)-((LEN(A1)-FIND("/",A1))+1)))),LARGE(INDEX(ISNUMBER(--MID((LEFT(A1,(LEN(A1)-((LEN(A1)-FIND("/",A1))+1)))),ROW(\$1:\$25),1))* ROW(\$1:\$25),0),ROW(\$1:\$25))+1,1)*10^ROW(\$1:\$25)/10)
``````
Assuming your data in column A.

Thanks
Commented:
Another option is to use leading zeroes.  For example: use GigabitEthernet1/02 instead of GigabitEthernet1/2.
Author Commented:
Adding "0" before that digit is simple thing but I guess you wont get solution what you looking for i.e. sorting.

``````=LEFT(A1,(FIND("/",A1)-1))&("/0"&MID(A1,FIND("/",A1)+1,LEN(A1)-FIND("/",A1,1)))
``````
Thanks
Commented:
I wasn't clear enough.  I should have said: "use leading zeroes when there is a single digit after the slash".

I used itjockey's formula but made it conditional:
=IF(FIND("/",A1)=LEN(A1)-1,LEFT(A1,(FIND("/",A1)-1))&("/0"&MID(A1,FIND("/",A1)+1,LEN(A1)-FIND("/",A1,1))),A1)

Basically, if the second to last character is "/", then use his formula to add the 0.  If not, don't make any changes.

You could then sort both columns based on the new one and you'd have your original data sorted as you wish without the leading zeroes displayed.

This assumes, of course, that there will be no more than 2 digits after the /.  If you need to allow for a third digit the formula could be extended.
``````=LEFT(A1,(FIND("/",A1)-1))&"/"&IF(LEN(A1)-FIND("/",A1)=1,"000",IF(LEN(A1)-FIND("/",A1)=2,"00",""))&MID(A1,FIND("/",A1)+1,LEN(A1)-FIND("/",A1,1))
``````
Thanks
oops Mr.CompProbSolv,

seen your comment after posting mine as my browser not auto refresh.
Microsoft Excel ExpertCommented:
i think Flyster solution is simple and working.   you simply use that and then use the sort a-z from the Data tab.
Commented:
Assuming the data is in Column A.

Another possible solution without using formulas is to:
1. Copy the column contents to an adjacent column - Column B
2. Do Text-to-Column on Column B with delimiter as "/"
3. Sort using Column B and Column C

This solution is independent of number of digits after "/".
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.