diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-01-10 20:35:53 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-01-10 20:35:53 +0100 |
| commit | 782154da11975b9db4620d7d39df3b567f3abcdc (patch) | |
| tree | 8cfe110e53ccfcee7a06421d6367b88d51d60add /addons/web/static/src/js/core/utils.js | |
| parent | 61bb46c82ba8113dddc0a95bd86cb029fbbf110e (diff) | |
| parent | f6ef0c776096774fc4c6821449ab42cfc2f53e62 (diff) | |
[MERGE] forward port branch saas-11.1 up to f6ef0c77609
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 |
