diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-01-10 11:41:35 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-01-10 11:41:35 +0100 |
| commit | 228ecdbe28246b0031a9cf7e63b90f4ae11131df (patch) | |
| tree | 33a3c3807c98ee79352abce486decd365e33b1b9 /addons/web/static/src/js/core/utils.js | |
| parent | 8270b212909de5cb26e958c023a4f0a27947eeef (diff) | |
| parent | ff0abd214c89dce19984ed0f3c72ea556e23da01 (diff) | |
[MERGE] forward port branch 11.0 up to ff0abd214c8
Diffstat (limited to 'addons/web/static/src/js/core/utils.js')
| -rw-r--r-- | addons/web/static/src/js/core/utils.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/web/static/src/js/core/utils.js b/addons/web/static/src/js/core/utils.js index 3fc88ac5b20..99534708a94 100644 --- a/addons/web/static/src/js/core/utils.js +++ b/addons/web/static/src/js/core/utils.js @@ -349,6 +349,23 @@ var utils = { ].join(';'); }, /** + * Sort an array in place, keeping the initial order for identical values. + * + * @param {Array} array + * @param {function} iteratee + */ + stableSort: function (array, iteratee) { + var stable = array.slice(); + return array.sort(function stableCompare (a, b) { + var order = iteratee(a, b); + if (order !== 0) { + return order; + } else { + return stable.indexOf(a) - stable.indexOf(b); + } + }); + }, + /** * @param {any} array * @param {any} elem1 * @param {any} elem2 |
