Solved

Reorder array information that has id and value data

Posted on 2016-10-13
2
51 Views
Last Modified: 2016-10-13
I have a SharePoint list that has a column that allows a user to prioritize or rearrange a list of projects.
Prioritize
I created a piece of it in jsfiddle using arrays.  I'm able to update the values but unable to shift the numbers and order
https://jsfiddle.net/isogunro/btft1Lys/

My goal is to implement the solution with this fiddle.
https://jsfiddle.net/isogunro/sb4ohdkj/

Any help would be much appreciated.
0
Comment
Question by:Isaac
2 Comments
 
LVL 42

Accepted Solution

by:
zephyr_hex (Megan) earned 500 total points
ID: 41842864
Since you are modifying the original array when you do the value replacement, why not just use a sort on that array to get the items reordered?

ary.sort(function(a,b) {
    return a[1] - b[1];
});

Open in new window


Here is an updated version of your Fiddle
1
 
LVL 5

Author Closing Comment

by:Isaac
ID: 41842970
Thanks!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question