# Sorting based on numbers

Hi there,

Iam trying to make a sorting based on a counter but it seems that i get messup because when i try to sort some based on for example "3" all number that have a "3" will sorted as well and i dont want it. How can I sort ONLY the "3" and not the 13, 33, 23, 53, etc?
heres the code iam using

if (\$yixa2 =~ 3) {
\$tdtag3 = "</tr><tr>"; }
else {
\$tdtag3 = "";
}

Any ideas?
Polos
###### Who is Participating?
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 (\$yixa2 == 3) {
Commented:
\$tdtag3 = \$yixa2==3&&"</tr><tr>";

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.

Commented:
It seems that you would best be served by placing this into a hash, then sorting the hash values by number.

For purposes of example, I am going to create a hash; you would use your own data here.
my %values;
\$values{23} = 'caption0';
\$values{13} = 'caption1';
\$values{33} = 'caption2';
\$values{3} = 'caption3';

You could then use this code to print the :

foreach(sort {\$a <=> \$b} keys %values) {
print "<tr><td>\$values{\$_}</td><td>\$_</td></tr>\n";
}

This would yield:

<tr><td>caption3</td><td>3</td></tr>
<tr><td>caption1</td><td>13</td></tr>
<tr><td>caption0</td><td>23</td></tr>
<tr><td>caption2</td><td>33</td></tr>

Which is what I think you're trying to accomplish.

Otherwise, if you're only trying to find the value "3" by itself, you can use the expression,

if (\$x == 3) {
#do action
}

Good luck.
###### 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
Scripting Languages

From novice to tech pro — start learning today.