jQuery Move Item from one select box to another while retaining listing order
<p>I have this code that is working but when the item is moved, it shows up at the bottom of the list.  I'd prefer to keep the order alphabetical and have no idea where to start.</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;
&lt;title&gt;demo&lt;/title&gt;
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"&gt;&lt;/script&gt;

&lt;style type='text/css'&gt;
.whatever {
    width:200px;
    height:50px;
    overflow:auto
}
&lt;/style&gt;
&lt;script type='text/javascript'&gt;//&lt;![CDATA[ 
    $(window).load(function(){
    $('#select1').click(function(){
    $('#select1 option:selected').appendTo('#select2');
});

$('#select2').click(function(){
    $('#select2 option:selected').appendTo('#select1');
});

$('#select3').click(function(){
    $('#select3 option:selected').appendTo('#select4');
});

$('#select4').click(function(){
    $('#select4 option:selected').appendTo('#select3');
});
});//]]&gt;  
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
&lt;select multiple id="select1" class="whatever"&gt;
    &lt;option value="1"&gt;Option 1&lt;/option&gt;
    &lt;option value="2"&gt;Option 2&lt;/option&gt;
    &lt;option value="3"&gt;Option 3&lt;/option&gt;
    &lt;option value="4"&gt;Option 4&lt;/option&gt;
&lt;/select&gt;
&lt;img src="../Common/MultiSelect/img/switch.png"&gt;
&lt;select multiple id="select2" class="whatever"&gt;&lt;/select&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;select multiple id="select3" class="whatever"&gt;
    &lt;option value="1"&gt;Option 1&lt;/option&gt;
    &lt;option value="2"&gt;Option 2&lt;/option&gt;
    &lt;option value="3"&gt;Option 3&lt;/option&gt;
    &lt;option value="4"&gt;Option 4&lt;/option&gt;
&lt;/select&gt;
&lt;img src="../Common/MultiSelect/img/switch.png"&gt;
&lt;select multiple id="select4" class="whatever"&gt;&lt;/select&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
