Solved

Reorder array information that has id and value data

Posted on 2016-10-13
2
33 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 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now