jquery reorder code example
Example: jquery reorder elements
/*
FROM:
```
- 2
- 10
- 5
- 7
- 6
- 8
- 9
- 4
- 1
- 3
```
TO:
```
- 1
- 3
- 6
- 7
- 2
- 10
- 5
- 8
- 9
- 4
```
*/
var special = $("li").filter(isSpecial).sort(byText).prependTo("ul")
function isSpecial() {
var v = parseInt($(this).text())
return v === 1 || v === 3 || v === 6 || v === 7
}
function byText(a, b) {
return $(a).text().localeCompare($(b).text())
}