File: /var/www/tana/frontend/node_modules/locutus/php/array/sort.js.map
{"version":3,"sources":["../../../src/php/array/sort.js"],"names":["module","exports","sort","inputArr","sortFlags","i18nlgd","require","sorter","i","k","sortByReference","populateArr","$global","window","global","$locutus","php","locales","loc","sorting","a","b","aFloat","parseFloat","bFloat","aNumeric","bNumeric","iniVal","undefined","valArr","hasOwnProperty","push","length"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,IAAT,CAAeC,QAAf,EAAyBC,SAAzB,EAAoC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,UAAUC,QAAQ,8BAAR,CAAd;;AAEA,MAAIC,MAAJ;AACA,MAAIC,CAAJ;AACA,MAAIC,CAAJ;AACA,MAAIC,kBAAkB,KAAtB;AACA,MAAIC,cAAc,EAAlB;;AAEA,MAAIC,UAAW,OAAOC,MAAP,KAAkB,WAAlB,GAAgCA,MAAhC,GAAyCC,MAAxD;AACAF,UAAQG,QAAR,GAAmBH,QAAQG,QAAR,IAAoB,EAAvC;AACA,MAAIA,WAAWH,QAAQG,QAAvB;AACAA,WAASC,GAAT,GAAeD,SAASC,GAAT,IAAgB,EAA/B;AACAD,WAASC,GAAT,CAAaC,OAAb,GAAuBF,SAASC,GAAT,CAAaC,OAAb,IAAwB,EAA/C;;AAEA,UAAQb,SAAR;AACE,SAAK,aAAL;AACE;AACA;AACA;AACF,SAAK,oBAAL;AACE;AACA;AACA,UAAIc,MAAMH,SAASC,GAAT,CAAaC,OAAb,CAAqBZ,SAArB,CAAV;;AAEA,UAAIa,OAAOA,IAAIC,OAAf,EAAwB;AACtB;AACA;AACA;AACAZ,iBAASW,IAAIC,OAAb;AACD;AACD;AACF,SAAK,cAAL;AACE;AACAZ,eAAS,gBAAUa,CAAV,EAAaC,CAAb,EAAgB;AACv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OAAOG,MAAvB,EAA+BxB,GAA/B,EAAoC;AAClC;AACAG,gBAAYH,CAAZ,IAAiBqB,OAAOrB,CAAP,CAAjB;AACD;AACD,SAAOE,mBAAmBC,WAA1B;AACD,CAhHD","file":"sort.js","sourcesContent":["module.exports = function sort (inputArr, sortFlags) {\n // discuss at: http://locutus.io/php/sort/\n // original by: Kevin van Zonneveld (http://kvz.io)\n // revised by: Brett Zamir (http://brett-zamir.me)\n // improved by: Brett Zamir (http://brett-zamir.me)\n // note 1: SORT_STRING (as well as natsort and natcasesort) might also be\n // note 1: integrated into all of these functions by adapting the code at\n // note 1: http://sourcefrog.net/projects/natsort/natcompare.js\n // note 1: This function deviates from PHP in returning a copy of the array instead\n // note 1: of acting by reference and returning true; this was necessary because\n // note 1: IE does not allow deleting and re-adding of properties without caching\n // note 1: of property position; you can set the ini of \"locutus.sortByReference\" to true to\n // note 1: get the PHP behavior, but use this only if you are in an environment\n // note 1: such as Firefox extensions where for-in iteration order is fixed and true\n // note 1: property deletion is supported. Note that we intend to implement the PHP\n // note 1: behavior by default if IE ever does allow it; only gives shallow copy since\n // note 1: is by reference in PHP anyways\n // note 1: Since JS objects' keys are always strings, and (the\n // note 1: default) SORT_REGULAR flag distinguishes by key type,\n // note 1: if the content is a numeric string, we treat the\n // note 1: \"original type\" as numeric.\n // example 1: var $arr = ['Kevin', 'van', 'Zonneveld']\n // example 1: sort($arr)\n // example 1: var $result = $arr\n // returns 1: ['Kevin', 'Zonneveld', 'van']\n // example 2: ini_set('locutus.sortByReference', true)\n // example 2: var $fruits = {d: 'lemon', a: 'orange', b: 'banana', c: 'apple'}\n // example 2: sort($fruits)\n // example 2: var $result = $fruits\n // returns 2: {0: 'apple', 1: 'banana', 2: 'lemon', 3: 'orange'}\n // test: skip-1\n\n var i18nlgd = require('../i18n/i18n_loc_get_default')\n\n var sorter\n var i\n var k\n var sortByReference = false\n var populateArr = {}\n\n var $global = (typeof window !== 'undefined' ? window : global)\n $global.$locutus = $global.$locutus || {}\n var $locutus = $global.$locutus\n $locutus.php = $locutus.php || {}\n $locutus.php.locales = $locutus.php.locales || {}\n\n switch (sortFlags) {\n case 'SORT_STRING':\n // compare items as strings\n // leave sorter undefined, so built-in comparison is used\n break\n case 'SORT_LOCALE_STRING':\n // compare items as strings, based on the current locale\n // (set with i18n_loc_set_default() as of PHP6)\n var loc = $locutus.php.locales[i18nlgd()]\n\n if (loc && loc.sorting) {\n // if sorting exists on locale object, use it\n // otherwise let sorter be undefined\n // to fallback to built-in behavior\n sorter = loc.sorting\n }\n break\n case 'SORT_NUMERIC':\n // compare items numerically\n sorter = function (a, b) {\n return (a - b)\n }\n break\n case 'SORT_REGULAR':\n default:\n sorter = function (a, b) {\n var aFloat = parseFloat(a)\n var bFloat = parseFloat(b)\n var aNumeric = aFloat + '' === a\n var bNumeric = bFloat + '' === b\n\n if (aNumeric && bNumeric) {\n return aFloat > bFloat ? 1 : aFloat < bFloat ? -1 : 0\n } else if (aNumeric && !bNumeric) {\n return 1\n } else if (!aNumeric && bNumeric) {\n return -1\n }\n\n return a > b ? 1 : a < b ? -1 : 0\n }\n break\n }\n\n var iniVal = (typeof require !== 'undefined' ? require('../info/ini_get')('locutus.sortByReference') : undefined) || 'on'\n sortByReference = iniVal === 'on'\n populateArr = sortByReference ? inputArr : populateArr\n\n var valArr = []\n for (k in inputArr) {\n // Get key and value arrays\n if (inputArr.hasOwnProperty(k)) {\n valArr.push(inputArr[k])\n if (sortByReference) {\n delete inputArr[k]\n }\n }\n }\n\n valArr.sort(sorter)\n\n for (i = 0; i < valArr.length; i++) {\n // Repopulate the old array\n populateArr[i] = valArr[i]\n }\n return sortByReference || populateArr\n}\n"]}