angular-ui/ui-select2 — pull request #78 by animator013 (2013-09-11 10:56:24+00:00)
Title: Fix for auto sorting items in select element

There is a problem with select2 that if i had some optgroups and items in it and if i selected 1 item from the second and 1 item from the first, the second item was moved to first position.

I found in angular.js:

```javascript
selectElement.bind('change', function() {
scope.$apply(function() {
var array = [];
forEach(selectElement.find('option'), function(option) {
if (option.selected) {
array.push(option.value);
}
});
ctrl.$setViewValue(array);
});
});
```

that model is being filled by iterating the selected options in select element. So if we do this in ui-select2:
```javascript
controller.$render = function () {
if (isSelect) {
elm.select2('val', controller.$viewValue);
}
...
}
```

We actually update the element with model values and "resort" all items by the model. This is not a good approach I think.

I made a fix for it so the render will hit select element once (items get sorted at the beginning by model) and then after selecting options only model gets updated and items will be added. But they wont sync and user wont be confused by item getting away by sorting.