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

  • SEARCH
  • Home
  • 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 8484455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:23:07+00:00 2026-06-10T20:23:07+00:00

I am trying to use the .sort() function to sort a list so: <div

  • 0

I am trying to use the .sort() function to sort a list so:

<div class="centerCnt">
    <div class="widgetHelp" id="5">a</div>
    <div class="widgetHelp" id="1">b</div>
    <div class="widgetHelp" id="2">c</div>
    <div class="widgetHelp" id="3">d</div>
</div>

I tried something like:

list = $(".widgetHelp");
list.sort(function(a, b) {
    var aProp = parseInt($(a).attr('id').replace('help_id_','')),
        bProp = parseInt($(b).attr('id').replace('help_id_',''));
    return (aProp > bProp ? 1 : aProp < bProp ? -1 : 0);
});

With terrible result… can someone show me the light?

  • 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-10T20:23:09+00:00Added an answer on June 10, 2026 at 8:23 pm

    jQuery doesn’t publicly implement the .sort method, it’s a hidden method because it doesn’t implement the usual jquery-like interface and is meant for internal use only. With that said, you can still use it, it hasn’t changed since it was added to the library. Try this:

    list = $(".widgetHelp");
    parent = list.parent();
    list.sort(function(a, b) {
        var aProp = parseInt($(a).attr('id').replace('help_id_','')),
            bProp = parseInt($(b).attr('id').replace('help_id_',''));
        return (aProp > bProp ? 1 : aProp < bProp ? -1 : 0);
    });
    parent.append(list);
    

    http://jsfiddle.net/rz5gL/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use stl sort() in a class function. I would like to
I'd like to use stl sort with a class comparison function greater that uses
I am trying to use a sorting function for grade, which will sort name
I am trying to use a list which is passed to a function in
I'm trying to use the bubble sort method to sort an array of only
I am trying to use MPI to sort digits, after sorting by the different
I'm trying to use Twisted in a sort of spidering program that manages multiple
I am trying to use jQuery's draggable and sortable to sort elements listed inside
I'm trying to use TF-IDF to sort documents into categories. I've calculated the tf_idf
I'm trying to sort a vector of objects using a predicate function and I'm

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.