0

I'm a beginner on JavaScript and I would ask your help for a problem:

In fact, I want to display equipments name by their number, but before the number I have alphabetical letter, for example:

meh10; meh120; meh20; meh614; switch12; switch130; switch20;...

I don't know how to sort it alphanumerically.

3
  • 1
    what you have try so far? show your html.. Commented Jul 16, 2014 at 11:20
  • function sort() { $($('ol.toBeSorted>li').get().reverse()).each(function(outer) { var sorting = this; $($('ol.toBeSorted>li').get().reverse()).each(function(inner) { if($('span.Node', this).text().localeCompare($('span.Node', sorting).text()) > 0) { this.parentNode.insertBefore(sorting.parentNode.removeChild(sorting), this); } }); }); } Commented Jul 16, 2014 at 11:24
  • HTML <ol class="toBeSorted"> {% for node in tree.iter %} {% if node.attrib.for == '0' %} <li> <a href="javascript:visibilite('{{node.attrib.value}}'); return false;"><span class="Node" title = "node" style = 'text-align : center'> {{ node.attrib.value }}</span></a> <div id= {{node.attrib.value}} style="display:none;"> {% endif %} {% endfor %} </li> <script type="text/javascript"> sort('il.toBeSorted>li', 'a'); </script> </ol> Commented Jul 16, 2014 at 11:28

1 Answer 1

1

I recommend this jquery plugin: http://tinysort.sjeiti.com/

Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your answer. I will try it right know and will tell you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.