Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | Source Code | 0 0
  1. $( document ).ready(function() {
  2. $("#panel > header > div.bar > div.nav-main > div.inner").append('<div id="zSortButton" data-role="button">$_Sort</div>');
  3. $("#zSortButton").on("click", function(){
  4. var parentArray = new Array();
  5. var sortedHTML = "";//<p>intro</p>";
  6. $('.post-list .post').each(function( index ) {
  7. var childArray = new Array([index],[$(this).wrap('<p/>').parent().html()],[$(this).find("a.comments").text().replace(' comments','').replace(' comment','')]);
  8. parentArray.push(childArray);
  9. });
  10. parentArray.sort(function(a, b) {
  11. return b[2] - a[2];
  12. });
  13. for (i = 0; i < parentArray.length; i++){
  14. sortedHTML = sortedHTML + parentArray[i][1];
  15. }
  16. $('.post-list').html(sortedHTML);
  17. });
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement