Order jQuery UI Sortable through An Array

I am using jQuery's Sortable UI (http://jqueryui.com/demos/sortable/#option-connectWith) for part of a quiz I am creating that will ask the user to sort list items in the correct order.

I have managed to save a users selection by iterating through my list items and storing the class names for each item as a comma-delimited string.

Is there a way for me to be able to parse an array of values to jQuery Sortable plugin in order to sort my list in order as presented within the array?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
Sorry I do not get what you are trying to do, please elaborate
R1ND3RAuthor Commented:
I basically would like to pass array of values to the jQuery Sortable plugin. The plugin is applied to the following list:

	$(function() {
		$( "#sortable" ).sortable();
		$( "#sortable" ).disableSelection();

<ul id="sortable">
	<li class="b">Item 2</li>
	<li class="d">Item 4</li>
	<li class="a">Item 1</li>
	<li class="c">Item 3</li>

Open in new window

As you can see, from the code above, when a user views the page they have to sort the items in correct order. I am using the "class" attribute as values to store to a variable in a comma-delimited string format on button click.

The values a user submits to a variable could be: "b, a, d , c". I have already created this functionality by iterating through all <li> in jQuery and storing them.

All I would like to be able to do is be able to reorder the list items by passing the variable containing  "b, a, d , c" to some function.
Michel PlungjanIT ExpertCommented:
Found a script for you

From the comments of http://stackoverflow.com/a/6764672/295783


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

R1ND3RAuthor Commented:
Thanks for your help mplungjan. Using your info has actually helped me with another part of my site.

I also managed to find through your StackOverflow like a related post that I found very useful: http://stackoverflow.com/questions/2858121/convert-javascript-comma-separated-string-into-an-array
R1ND3RAuthor Commented:
The reply didn't fully solve my issue. But the link provided me with some good info to look into.
Michel PlungjanIT ExpertCommented:
Great - I am not sure, however how the fiddle did not help you to fully achieve your goal of having the li's sorted initially.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.