In this article , sort my lookup column based on a column
<script type="text/javascript" language="javascript">
$().SPServices.SPFilterDropdown({ //This is the function that does the sorting.
relationshipList: "Code", //This is the name of the lookup field in the form.
relationshipListColumn: "Title", //This is the original column name from the lookup list as SharePoint knows it.
relationshipListSortColumn: "Sortby"
columnName: "Code", //This is the column name in the lookup list as it shows up.
CAMLQuery: "<Neq><FieldRef Name='Title'/><Value Type='Text'></Value></Neq>", //This is the CAML Query if you want to select a specific set of items from the list. In this example it doesn't select items where the Title column is null. Note, the Title column is the original column name.
debug: true
});
</script>