{"version":3,"sources":["webpack:///bundle.js","webpack:///webpack/bootstrap 87d8b22c3e8e915d4367","webpack:///./test.js","webpack:///./sorted.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_sorted","window","test","result","fancySort","console","log","comparer","a","b","ma","exec","mb","na","nb","binaryLookup","ar","length","found","index","r","mid","Math","floor","input","reduce","_binaryLookup","splice","value"],"mappings":"CAAS,SAAUA,GCInB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAI,EAAAJ,EACAK,GAAA,EACAH,WAUA,OANAJ,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,GAAA,EAGAF,EAAAD,QAvBA,GAAAD,KA4BAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EAAA,SAAAP,EAAAQ,EAAAC,GACAZ,EAAAa,EAAAV,EAAAQ,IACAG,OAAAC,eAAAZ,EAAAQ,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAf,GACA,GAAAQ,GAAAR,KAAAgB,WACA,WAA2B,MAAAhB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAJ,GAAAU,EAAAE,EAAA,IAAAA,GACAA,GAIAZ,EAAAa,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAjB,KAAAc,EAAAC,IAGtDtB,EAAAyB,EAAA,GAGAzB,IAAA0B,EAAA,KDMM,SAAUtB,EAAQD,EAASH,GAEjC,YErEA,IAAA2B,GAAA3B,EAAA,EAEA4B,QAAOC,KAAO,WACZ,GAAIA,IAAQ,SAAU,IAAK,QAAS,KAChCC,GAAS,EAAAH,EAAAI,WAAUF,EACvBG,SAAQC,IAAIH,KF6ER,SAAU1B,EAAQD,EAASH,GAEjC,YGpFA,SAASkC,GAASC,EAAGC,GACnB,GAAMC,GAAK,aAAaC,KAAKH,GACvBI,EAAK,aAAaD,KAAKF,EAC7B,IAAU,MAANC,GAAoB,MAANE,GAAcF,EAAG,IAAME,EAAG,GAC1C,MAAOJ,GAAIC,GAAK,EAAID,EAAIC,EAAI,EAAI,CAEhC,IAAMI,IAAMH,EAAG,GACbI,GAAMF,EAAG,EACX,OAAOC,GAAKC,GAAM,EAAID,EAAKC,EAAK,EAAI,EAIxC,QAASC,GAAaC,EAAItC,EAAG6B,GAC3B,GAAiB,GAAbS,EAAGC,OACL,OAASC,OAAO,EAAOC,MAAO,EAIhC,KAFA,GAAIxC,GAAI,EACNyC,EAAIJ,EAAGC,OAAS,EACXtC,EAAIyC,GAAG,CACZ,GAAMC,GAAMC,KAAKC,OAAO5C,EAAIyC,GAAK,EAC7Bb,GAASS,EAAGK,GAAM3C,GAAK,EACzBC,EAAI0C,EAAM,EAEVD,EAAIC,EAGR,GAAMlB,GAASI,EAASS,EAAGrC,GAAID,EAC/B,OAAe,KAAXyB,GACOe,OAAO,EAAMC,MAAOxC,IAG7BuC,OAAO,EACPC,MAAOhB,EAAS,EAAIxB,EAAI,EAAIA,GAIzB,QAASyB,GAAUoB,GACxB,MAAOA,GAAMC,OAAO,SAACT,EAAItC,GAAM,GAAAgD,GACXX,EAAaC,EAAItC,EAAG6B,GAA9BY,EADqBO,EACrBP,KAER,OADAH,GAAGW,OAAOR,EAAO,EAAGzC,GACbsC,OH+CX7B,OAAOC,eAAeZ,EAAS,cAC7BoD,OAAO,IAETpD,EGtDgB4B","file":"bundle.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _sorted = __webpack_require__(1);\n\nwindow.test = function () {\n var test = [\"b (30)\", \"a\", \"b (5)\", \"z\"];\n var result = (0, _sorted.fancySort)(test);\n console.log(result);\n};\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.fancySort = fancySort;\nfunction comparer(a, b) {\n var ma = /.(\\d+)\\W*$/.exec(a);\n var mb = /.(\\d+)\\W*$/.exec(b);\n if (ma == null || mb == null || ma[1] == mb[1]) {\n return a < b ? -1 : a > b ? 1 : 0;\n } else {\n var na = +ma[1],\n nb = +mb[1];\n return na < nb ? -1 : na > nb ? 1 : 0;\n }\n}\n\nfunction binaryLookup(ar, i, comparer) {\n if (ar.length == 0) {\n return { found: false, index: 0 };\n }\n var l = 0,\n r = ar.length - 1;\n while (l < r) {\n var mid = Math.floor((l + r) / 2);\n if (comparer(ar[mid], i) < 0) {\n l = mid + 1;\n } else {\n r = mid;\n }\n }\n var result = comparer(ar[l], i);\n if (result === 0) {\n return { found: true, index: l };\n }\n return {\n found: false,\n index: result < 0 ? l + 1 : l\n };\n}\n\nfunction fancySort(input) {\n return input.reduce(function (ar, i) {\n var _binaryLookup = binaryLookup(ar, i, comparer),\n index = _binaryLookup.index;\n\n ar.splice(index, 0, i);\n return ar;\n }, []);\n}\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// bundle.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 87d8b22c3e8e915d4367","import { fancySort } from \"./sorted.js\";\n\nwindow.test = function() {\n let test = [\"b (30)\", \"a\", \"b (5)\", \"z\"];\n let result = fancySort(test);\n console.log(result);\n};\n\n\n\n// WEBPACK FOOTER //\n// ./test.js","function comparer(a, b) {\n const ma = /.(\\d+)\\W*$/.exec(a);\n const mb = /.(\\d+)\\W*$/.exec(b);\n if (ma == null || mb == null || ma[1] == mb[1]) {\n return a < b ? -1 : a > b ? 1 : 0;\n } else {\n const na = +ma[1],\n nb = +mb[1];\n return na < nb ? -1 : na > nb ? 1 : 0;\n }\n}\n\nfunction binaryLookup(ar, i, comparer) {\n if (ar.length == 0) {\n return { found: false, index: 0 };\n }\n let l = 0,\n r = ar.length - 1;\n while (l < r) {\n const mid = Math.floor((l + r) / 2);\n if (comparer(ar[mid], i) < 0) {\n l = mid + 1;\n } else {\n r = mid;\n }\n }\n const result = comparer(ar[l], i);\n if (result === 0) {\n return { found: true, index: l };\n }\n return {\n found: false,\n index: result < 0 ? l + 1 : l\n };\n}\n\nexport function fancySort(input) {\n return input.reduce((ar, i) => {\n const { index } = binaryLookup(ar, i, comparer);\n ar.splice(index, 0, i);\n return ar;\n }, []);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./sorted.js"],"sourceRoot":""}