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 7004611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:13:15+00:00 2026-05-27T21:13:15+00:00

I am really lost with trying to order an ul list by the span

  • 0

I am really lost with trying to order an ul list by the span in the li.

I have this next structure

<ul id="videosList">
  <li class="response1">
    <a href="link"><img src="moon" /><span>Alex breaking bad</span>
      <li>
        <li class="response1">
          <a href="link"><img src="moon" /><span>Jason playing piano</span>
            <li>
              <li class="response1">
                <a href="link"><img src="moon" /><span>Jenny skying</span>
                  <li>
                    <li class="response1">
                      <a href="link"><img src="moon" /><span>Chuck norris</span>
                        <li>
                          <li class="response1">
                            <a href="link"><img src="moon" /><span>Zyxwaa</span>
                              <li>
                                <li class="response1">
                                  <a href="link"><img src="moon" /><span>Realtek</span>
                                    <li>

                                      <li class="response2">
                                        <a href="link"><img src="moon" /><span>Bad alex breaking</span>
                                          <li>
                                            <li class="response2">
                                              <a href="link"><img src="moon" /><span>Piano playing Jason</span>
                                                <li>
                                                  <li class="response2">
                                                    <a href="link"><img src="moon" /><span>Skying Jenny</span>
                                                      <li>
                                                        <li class="response2">
                                                          <a href="link"><img src="moon" /><span>Norris chuck</span>
                                                            <li>
                                                              <li class="response2">
                                                                <a href="link"><img src="moon" /><span>Intel</span>
                                                                  <li>
</ul>

I have that list generated from some uploaded videos and separated because respnse1 brings videos from X database and response brings videos from Y database. What I want to do is to order the list by the content of the SPAN in LI.

I’ve tried a few things from Google and Stack Overflow but I couldn’t adapt any 1 to fit what I need.

So that’s it, how can I order a list with JavaScript/jQuery by the content of SPAN in LI?

  • 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-05-27T21:13:16+00:00Added an answer on May 27, 2026 at 9:13 pm

    it works!…

    var list = $("ul#videosList");
    var desc= false;
    list.append(list.children().get().sort(function(a, b) {
        var aProp = $(a).find("span").text(),
            bProp = $(b).find("span").text();
        return (aProp > bProp ? 1 : aProp < bProp ? -1 : 0) * (desc ? -1 : 1);
    }));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm really lost on this case. I am trying to apply a custom MVC
This is probably really easy, but I'm lost on how to make sure it
Really ripping my hair out on this one. I have a JAAS Authentication Provider
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
We've been seeing this problem for a while now and I'm really trying to
I am really at a loss here, and have been trying to find a
I'm trying to build an object that looks something like this: public class MyObject
I am trying to build a TreeView and have it set up like this
I have been trying to search answer for this, but all discussions that I
i'm really lost on some code. Im trying to draw a dayview calendar with

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.