0

This is what I have

$wrapper.find('li').sort(function (a, b) {
  return +a.getAttribute('data-val') - +b.getAttribute('data-val');
});

It works, as I see in Chrome dev tool an array of objects is indeed returned but...my question is: What's up with that return? How can I use that array?

What I want to do i to take the returned array, and stick it inside a tag.

2

1 Answer 1

6

Simply assign it:

yourArray = $wrapper.find('li').sort(function (a, b) {
  return +a.getAttribute('data-val') - +b.getAttribute('data-val');
});

You can then use yourArray.

Sign up to request clarification or add additional context in comments.

1 Comment

I can't believe I didn't get it! I'm sure I tried something similar but clearly made some mistakes! Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.