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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:46:57+00:00 2026-05-26T02:46:57+00:00

I have an array of elements: markers and a table which updates it’s rows

  • 0

I have an array of elements: markers and a table which updates it’s rows to populate with the data stored within markers. markers itself houses an object marker which has a latitude and longitude amongst other things.

When I populate the table with the details from the markers array I give each row an ID based on i as it loops through.

On this table I have jQuery sortable. I am looking for a way to re-order my markers array each time the rows are sorted, so that the position of the item in the array is actually it’s sort order value. That way, I can simply loop through the array at any time and see it’s most up to date order.

So far I have the table generating as should and the markers array populated. I am even able to grab back the order of the rows after shuffling them around, at the moment I store them in an array orders and just alert, this works (ie. 0,1,2 > dragged to resort > 2,0,1). I was hoping for a way of now using the set of values in orders to resort my original markers array.

I thought it would involve creating a temporary array markersTemp with which to store the values saved in markers but in the new order, except I’m not sure how to loop through to save each one. Anyone done anything similar?

  • 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-26T02:46:57+00:00Added an answer on May 26, 2026 at 2:46 am
    function resort() {
        var order = []; // Get the order of the new rows
        $('#createMapDirections tbody tr').each(function(i, elem){
            order.push(markers[getId($("td", elem))]);
        });
        markers = order;
        updateAll();
    }
    

    Old procedure:

    1. Create a new list order
    2. Loop through the current rows in the table.
      Store the IDs at the current rows in list order
    3. Create a new list markersTemp
    4. Loop through list order
      Get the ID at position i in list order.
      Let markersTemp[i] be the element in markers (referred at the old position through id)
    5. Reset markers
    6. Set markers to markersTemp

    Optimized:

    1. Create a new list order
    2. Loop through each row in the table.
      Push the element, as referred by the index as returned from getId() in order
    3. Overwrite markers by order.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider I have an array of elements out of which I want to create
I have an array Items which has 10 elements. I need to remove the
I have an array which i need to sort its elements by occurrence then
Let's say I have an array, @theArr, which holds 1,000 or so elements such
I have an array $abc which has 9 elements, as:- Array ( [a] =>
Let's say I have an array of elements for which a total ordering exists.
I have an array of elements #document h1, #content h2 which I know may
I have an array (of 9 elements, say) which I must treat as a
I have an array, whose size is 256. This array has elements which are
VISUAL C++ Question Hi, I have array of 3 elements and I want to

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.