Rearrange Elements with jQuery

Rearrange HTML elements using jQuery.

HTML

<ul>
    <li class="first">1</li>
    <li>2</li>
    <li>3</li>
</ul>

JavaScript

console.log($('.first').index());
$('.first').insertAfter('li:nth-child(3)');
//$('li:nth-child(3)').prependTo('li:nth-child(2)');
console.log($('.first').index());