Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7961053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:55:32+00:00 2026-06-04T04:55:32+00:00

Edit: 2 var elems = $(#D li).toArray(); elems.sort(function(a, b) { var adate = new

  • 0

Edit: 2

var elems = $("#D li").toArray();
elems.sort(function(a, b) {
    var adate = new Date($(a).find('div.dateDiv').text());
    var bdate = new Date($(b).find('div.dateDiv').text());
    return adate > bdate ? -1 : 1;
});
$("#D").html(elems);


<div id="D">
    <li>1<div class="dateDiv">2012-04-15 10:25:45</div><div>df</div></li> 
    <li>2 <div class="dateDiv">2012-04-10 19:41:08</div><div>df</div></li> 
    <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div><div>ab</div></li> 
    <li>4 <div class="dateDiv">2012-04-12 16:45:50</div><div>a</div></li>

     <li>1<div class="dateDiv">2012-04-15 10:25:45</div></li>
   <li>2 <div class="dateDiv">2012-04-10 19:41:08</div></li>
  <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div></li>
   <li>4 <div class="dateDiv">2012-04-12 16:45:50</div></li>


      <li>1<div class="dateDiv">2012-04-15 10:25:45</div></li>
   <li>2 <div class="dateDiv">2012-04-10 19:41:08</div></li>
  <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div></li>
   <li>4 <div class="dateDiv">2012-04-12 16:45:50</div></li>


      <li>1<div class="dateDiv">2012-04-15 10:25:45</div></li>
   <li>2 <div class="dateDiv">2012-04-10 19:41:08</div></li>
  <li> 3 <div class="dateDiv">2012-04-20 07:00:10</div></li>
   <li>4 <div class="dateDiv">2012-04-12 16:45:50</div></li>
</div>​

i try it many times
some problem with Firefox browser or IE or safari it’s work only with opera and chrome ,
any one help ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:55:34+00:00Added an answer on June 4, 2026 at 4:55 am

    Edit: to sort the li’s: http://jsfiddle.net/katylava/dsNCX/13/

    var elems = $("#D li").toArray();
    elems.sort(function(a, b) {
        var adate = new Date($(a).find('div.dateDiv').text());
        var bdate = new Date($(b).find('div.dateDiv').text());
        return adate > bdate ? -1 : 1;
    });
    $("#D").html(elems);
    

    ^^^final solution comes from @MerlynMorgan-Graham’s deleted answer, not me

    Edit: the previous solution does not work in FF because it doesn’t like the date format. So replace the space with a ‘T’. However, this still does not work in Safari. http://jsfiddle.net/dsNCX/17/

    var elems = $("#D li").toArray();
    elems.sort(function(a, b) {
        var adate = new Date($(a).find('div.dateDiv').text().replace(' ', 'T'));
        var bdate = new Date($(b).find('div.dateDiv').text().replace(' ', 'T'));
        return adate > bdate ? -1 : 1;
    });
    $("#D").html(elems);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT : Per Slaks $j('#banner-content img').each(function() { var link = $j('#page-tabs li a.' +
sort() orders the elemts alphabetically: var fruits = new Array("Apple", "Banana", "Kiwi", "Ananas", "Mango");
http://jsbin.com/eyeqer/2/edit var x = document.evaluate('//p/following-sibling::text()', document, null, XPathResult.ANY_TYPE, null); var theTitle = x.iterateNext(); while
Please see my code here http://jsbin.com/ijoxa3/edit var drawHorizondalLine = function(x1,y1,x2,y2, color) { var width
I've implemented a jqgrid with inline edit: var lastSel; jQuery(document).ready(function () { jQuery(#list).jqGrid({ url:
Possible Duplicate: C# 'var' keyword versus explicitly defined variables EDIT: For those who are
Edit: We can close. Isn't truly asynchronous, non-blocking javascript impossible? var PATH = require
the second function isnt working? $('.edit_hover').live('hover', function(e){ $(this).stop(); var half_width = ($(this).css('width').slice(0, -2))/2; var
Using jQuery, I make these changes in the DOM: $(document).ready(function() { $('.editable').click(function() { var
Problem is that onkeydown=doSearch gives error that can not find dosearch function which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.