how can i sort all officers based on their ranks
jQuery
$.get('officers.xml', function(grade){
    $(grade).find('officer').each(function(){
        var $rank = $(this).attr('rank');
    });
});
XML (officer.xml)
<grade>
 <officer rank="2"></student>
 <officer rank="3"></student>
 <officer rank="1"></student>
</grade>
thanks.
$.get('officers.xml', function(grade){     
  var officer = $(grade).find('officer');
  officer.sort(function(a, b){
     return (parseInt($(a).attr('rank')) - parseInt($(b).attr('rank')));
  });
  officer.each(function(i,v){
    alert($(v).attr('rank'));
  });
});    
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With