Best JavaScript code snippet using best
bootstrap-table-multiple-sort.js
Source:bootstrap-table-multiple-sort.js
...84 sortName: name,85 sortOrder: order86 };87 });88 var sorted_fields = fields.sort();89 for (var i = 0; i < fields.length - 1; i++) {90 if (sorted_fields[i + 1] == sorted_fields[i]) {91 results.push(sorted_fields[i]);92 }93 }94 if (results.length > 0) {95 if ($alert.length === 0) {96 $alert = '<div class="alert alert-danger" role="alert"><strong>' + that.options.formatDuplicateAlertTitle() + '</strong> ' + that.options.formatDuplicateAlertDescription() + '</div>';97 $($alert).insertBefore(that.$sortModal.find('.bars'));98 }99 } else {100 if ($alert.length === 1) {101 $($alert).remove();102 }103 that.$sortModal.modal('hide');104 that.options.sortName = '';105 if (that.options.sidePagination === 'server') {106 that.options.queryParams = function(params) {107 params.multiSort = that.options.sortPriority;108 return params;109 };110 that.initServer(that.options.silentSort);111 return;112 }113 that.onMultipleSort();114 }115 });116 if (that.options.sortPriority === null || that.options.sortPriority.length === 0) {117 if (that.options.sortName) {118 that.options.sortPriority = [{119 sortName: that.options.sortName,120 sortOrder: that.options.sortOrder121 }];122 }123 }124 if (that.options.sortPriority !== null && that.options.sortPriority.length > 0) {125 if ($rows.length < that.options.sortPriority.length && typeof that.options.sortPriority === 'object') {126 for (var i = 0; i < that.options.sortPriority.length; i++) {127 that.addLevel(i, that.options.sortPriority[i]);128 }129 }130 } else {131 that.addLevel(0);132 }133 that.setButtonStates();134 }135 };136 $.extend($.fn.bootstrapTable.defaults, {137 showMultiSort: false,138 sortPriority: null,139 onMultipleSort: function() {140 return false;141 }142 });143 $.extend($.fn.bootstrapTable.defaults.icons, {144 sort: 'glyphicon-sort',145 plus: 'glyphicon-plus',146 minus: 'glyphicon-minus'147 });148 $.extend($.fn.bootstrapTable.Constructor.EVENTS, {149 'multiple-sort.bs.table': 'onMultipleSort'150 });151 $.extend($.fn.bootstrapTable.locales, {152 formatMultipleSort: function() {153 return 'Multiple Sort';154 },155 formatAddLevel: function() {156 return 'Add Level';157 },158 formatDeleteLevel: function() {159 return 'Delete Level';160 },161 formatColumn: function() {162 return 'Column';163 },164 formatOrder: function() {165 return 'Order';166 },167 formatSortBy: function() {168 return 'Sort by';169 },170 formatThenBy: function() {171 return 'Then by';172 },173 formatSort: function() {174 return 'Sort';175 },176 formatCancel: function() {177 return 'Cancel';178 },179 formatDuplicateAlertTitle: function() {180 return 'Duplicate(s) detected!';181 },182 formatDuplicateAlertDescription: function() {183 return 'Please remove or change any duplicate column.';184 },185 formatSortOrders: function() {186 return {187 asc: 'Ascending',188 desc: 'Descending'189 };190 }191 });192 $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);193 var BootstrapTable = $.fn.bootstrapTable.Constructor,194 _initToolbar = BootstrapTable.prototype.initToolbar;195 BootstrapTable.prototype.initToolbar = function() {196 this.showToolbar = true;197 var that = this,198 sortModalId = '#sortModal_' + this.$el.attr('id');199 this.$sortModal = $(sortModalId);200 _initToolbar.apply(this, Array.prototype.slice.apply(arguments));201 if (this.options.showMultiSort) {202 var $btnGroup = this.$toolbar.find('>.btn-group').first(),203 $multiSortBtn = this.$toolbar.find('div.multi-sort');204 if (!$multiSortBtn.length) {205 $multiSortBtn = ' <button class="multi-sort btn btn-default' + (this.options.iconSize === undefined ? '' : ' btn-' + this.options.iconSize) + '" type="button" data-toggle="modal" data-target="' + sortModalId + '" title="' + this.options.formatMultipleSort() + '">';206 $multiSortBtn += ' <i class="' + this.options.iconsPrefix + ' ' + this.options.icons.sort + '"></i>';207 $multiSortBtn += '</button>';208 $btnGroup.append($multiSortBtn);209 showSortModal(that);210 }211 this.$el.on('sort.bs.table', function() {212 isSingleSort = true;213 });214 this.$el.on('multiple-sort.bs.table', function() {215 isSingleSort = false;216 });217 this.$el.on('load-success.bs.table', function() {218 if (!isSingleSort && that.options.sortPriority !== null && typeof that.options.sortPriority === 'object' && that.options.sidePagination !== 'server') {219 that.onMultipleSort();220 }221 });222 this.$el.on('column-switch.bs.table', function(field, checked) {223 for (var i = 0; i < that.options.sortPriority.length; i++) {224 if (that.options.sortPriority[i].sortName === checked) {225 that.options.sortPriority.splice(i, 1);226 }227 }228 that.assignSortableArrows();229 that.$sortModal.remove();230 showSortModal(that);231 });232 this.$el.on('reset-view.bs.table', function() {233 if (!isSingleSort && that.options.sortPriority !== null && typeof that.options.sortPriority === 'object') {234 that.assignSortableArrows();235 }236 });237 }238 };239 BootstrapTable.prototype.onMultipleSort = function() {240 var that = this;241 var cmp = function(x, y) {242 return x > y ? 1 : x < y ? -1 : 0;243 };244 var arrayCmp = function(a, b) {245 var arr1 = [],246 arr2 = [];247 for (var i = 0; i < that.options.sortPriority.length; i++) {248 var order = that.options.sortPriority[i].sortOrder === 'desc' ? -1 : 1,249 aa = a[that.options.sortPriority[i].sortName],250 bb = b[that.options.sortPriority[i].sortName];251 if (aa === undefined || aa === null) {252 aa = '';253 }254 if (bb === undefined || bb === null) {255 bb = '';256 }257 if ($.isNumeric(aa) && $.isNumeric(bb)) {258 aa = parseFloat(aa);259 bb = parseFloat(bb);260 }261 if (typeof aa !== 'string') {262 aa = aa.toString();263 }264 arr1.push(265 order * cmp(aa, bb));266 arr2.push(267 order * cmp(bb, aa));268 }269 return cmp(arr1, arr2);270 };271 this.data.sort(function(a, b) {272 return arrayCmp(a, b);273 });274 this.initBody();275 this.assignSortableArrows();276 this.trigger('multiple-sort');277 };278 BootstrapTable.prototype.addLevel = function(index, sortPriority) {279 var text = index === 0 ? this.options.formatSortBy() : this.options.formatThenBy();280 this.$sortModal.find('tbody')281 .append($('<tr>')282 .append($('<td>').text(text))283 .append($('<td>').append($('<select class="form-control multi-sort-name">')))284 .append($('<td>').append($('<select class="form-control multi-sort-order">')))285 );...
summaryTableHeader.js
Source:summaryTableHeader.js
1const React = require('react');2function getSortDetails(sortKey, activeSort) {3 let newSort = { sortKey, order: 'desc' };4 let sortClass = '';5 if (activeSort && activeSort.sortKey === sortKey) {6 sortClass = 'sorted';7 if (activeSort.order === 'desc') {8 sortClass += '-desc';9 newSort.order = 'asc';10 } else {11 if (sortKey !== 'file') {12 newSort = { sortKey: 'file', order: 'desc' };13 }14 }15 }16 return {17 newSort,18 sortClass19 };20}21function SummaryTableHeaderCell({ name, onSort, sortKey, activeSort }) {22 const { newSort, sortClass } = getSortDetails(sortKey, activeSort);23 return (24 <th25 className={'sortable headercell ' + sortClass}26 onClick={() => onSort(newSort)}27 >28 {name}29 <span className="sorter" />30 </th>31 );32}33function FileHeaderCell({ onSort, activeSort }) {34 const { newSort, sortClass } = getSortDetails('file', activeSort);35 return (36 <th37 className={'sortable file ' + sortClass}38 onClick={() => onSort(newSort)}39 >40 File41 <span className="sorter" />42 </th>43 );44}45function SubHeadings({ sortKeyPrefix, onSort, activeSort }) {46 return (47 <>48 <SummaryTableHeaderCell49 name="%"50 onSort={onSort}51 sortKey={sortKeyPrefix + '.pct'}52 activeSort={activeSort}53 />54 <th className="headercell"></th>55 <SummaryTableHeaderCell56 name="Covered"57 onSort={onSort}58 sortKey={sortKeyPrefix + '.covered'}59 activeSort={activeSort}60 />61 <SummaryTableHeaderCell62 name="Missed"63 onSort={onSort}64 sortKey={sortKeyPrefix + '.missed'}65 activeSort={activeSort}66 />67 <SummaryTableHeaderCell68 name="Total"69 onSort={onSort}70 sortKey={sortKeyPrefix + '.total'}71 activeSort={activeSort}72 />73 </>74 );75}76module.exports = function SummaryTableHeader({77 onSort,78 activeSort,79 metricsToShow80}) {81 return (82 <thead>83 <tr className="topheading">84 <th></th>85 {metricsToShow.statements && <th colSpan={4}>Statements</th>}86 {metricsToShow.branches && <th colSpan={4}>Branches</th>}87 {metricsToShow.functions && <th colSpan={4}>Functions</th>}88 {metricsToShow.lines && <th colSpan={4}>Lines</th>}89 </tr>90 <tr className="subheading">91 <FileHeaderCell onSort={onSort} activeSort={activeSort} />92 {metricsToShow.statements && (93 <SubHeadings94 sortKeyPrefix="statements"95 onSort={onSort}96 activeSort={activeSort}97 />98 )}99 {metricsToShow.branches && (100 <SubHeadings101 sortKeyPrefix="branches"102 onSort={onSort}103 activeSort={activeSort}104 />105 )}106 {metricsToShow.functions && (107 <SubHeadings108 sortKeyPrefix="functions"109 onSort={onSort}110 activeSort={activeSort}111 />112 )}113 {metricsToShow.lines && (114 <SubHeadings115 sortKeyPrefix="lines"116 onSort={onSort}117 activeSort={activeSort}118 />119 )}120 </tr>121 </thead>122 );...
sort.ts
Source:sort.ts
1import { MongoDriverError } from './error';2/** @public */3export type SortDirection =4 | 15 | -16 | 'asc'7 | 'desc'8 | 'ascending'9 | 'descending'10 | { $meta: string };11/** @public */12export type Sort =13 | string14 | Exclude<SortDirection, { $meta: string }>15 | string[]16 | { [key: string]: SortDirection }17 | Map<string, SortDirection>18 | [string, SortDirection][]19 | [string, SortDirection];20/** Below stricter types were created for sort that correspond with type that the cmd takes */21/** @internal */22export type SortDirectionForCmd = 1 | -1 | { $meta: string };23/** @internal */24export type SortForCmd = Map<string, SortDirectionForCmd>;25/** @internal */26type SortPairForCmd = [string, SortDirectionForCmd];27/** @internal */28function prepareDirection(direction: any = 1): SortDirectionForCmd {29 const value = `${direction}`.toLowerCase();30 if (isMeta(direction)) return direction;31 switch (value) {32 case 'ascending':33 case 'asc':34 case '1':35 return 1;36 case 'descending':37 case 'desc':38 case '-1':39 return -1;40 default:41 throw new MongoDriverError(`Invalid sort direction: ${JSON.stringify(direction)}`);42 }43}44/** @internal */45function isMeta(t: SortDirection): t is { $meta: string } {46 return typeof t === 'object' && t !== null && '$meta' in t && typeof t.$meta === 'string';47}48/** @internal */49function isPair(t: Sort): t is [string, SortDirection] {50 if (Array.isArray(t) && t.length === 2) {51 try {52 prepareDirection(t[1]);53 return true;54 } catch (e) {55 return false;56 }57 }58 return false;59}60function isDeep(t: Sort): t is [string, SortDirection][] {61 return Array.isArray(t) && Array.isArray(t[0]);62}63function isMap(t: Sort): t is Map<string, SortDirection> {64 return t instanceof Map && t.size > 0;65}66/** @internal */67function pairToMap(v: [string, SortDirection]): SortForCmd {68 return new Map([[`${v[0]}`, prepareDirection([v[1]])]]);69}70/** @internal */71function deepToMap(t: [string, SortDirection][]): SortForCmd {72 const sortEntries: SortPairForCmd[] = t.map(([k, v]) => [`${k}`, prepareDirection(v)]);73 return new Map(sortEntries);74}75/** @internal */76function stringsToMap(t: string[]): SortForCmd {77 const sortEntries: SortPairForCmd[] = t.map(key => [`${key}`, 1]);78 return new Map(sortEntries);79}80/** @internal */81function objectToMap(t: { [key: string]: SortDirection }): SortForCmd {82 const sortEntries: SortPairForCmd[] = Object.entries(t).map(([k, v]) => [83 `${k}`,84 prepareDirection(v)85 ]);86 return new Map(sortEntries);87}88/** @internal */89function mapToMap(t: Map<string, SortDirection>): SortForCmd {90 const sortEntries: SortPairForCmd[] = Array.from(t).map(([k, v]) => [91 `${k}`,92 prepareDirection(v)93 ]);94 return new Map(sortEntries);95}96/** converts a Sort type into a type that is valid for the server (SortForCmd) */97export function formatSort(98 sort: Sort | undefined,99 direction?: SortDirection100): SortForCmd | undefined {101 if (sort == null) return undefined;102 if (typeof sort === 'string') return new Map([[sort, prepareDirection(direction)]]);103 if (typeof sort !== 'object') {104 throw new MongoDriverError(`Invalid sort format: ${JSON.stringify(sort)}`);105 }106 if (!Array.isArray(sort)) {107 return isMap(sort) ? mapToMap(sort) : Object.keys(sort).length ? objectToMap(sort) : undefined;108 }109 if (!sort.length) return undefined;110 if (isDeep(sort)) return deepToMap(sort);111 if (isPair(sort)) return pairToMap(sort);112 return stringsToMap(sort);...
sort_test.py
Source:sort_test.py
...9from chapter8.radix_sort import radix_sort10from chapter8.bucket_sort import bucket_sort11RANDOM_SORT_TEST_INPUT = 'test/random_sort_test_cases.json'12class SortTest(unittest.TestCase):13 def _test_sort(self, sort: Callable[[List[int], bool], List[int]]):14 test_cases = [15 ([4, 7, 1, 5, 8, 2, 6, 9, 10, 3], False, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),16 ([7, 6, 5, 4, 3, 2, 1], False, [1, 2, 3, 4, 5, 6, 7]),17 ([1, 2, 3, 4, 5, 6, 7], True, [7, 6, 5, 4, 3, 2, 1])18 ]19 for nums, reverse, expected in test_cases:20 result = sort(nums, reverse)21 self.assertEqual(expected, result)22 with open(RANDOM_SORT_TEST_INPUT) as f:23 random_test_cases = json.load(f)24 for nums in random_test_cases:25 result = sort(nums, False)26 benchmark = sorted(nums)27 self.assertEqual(result, benchmark)28 def test_insertion_sort(self):29 self._test_sort(insertion_sort)30 def test_merge_sort(self):31 self._test_sort(merge_sort)32 def test_heap_sort(self):33 def sort(nums: List[int], reverse: bool) -> List[int]:34 heap_sort(nums, reverse)35 return nums36 self._test_sort(sort)37 def test_quick_sort(self):38 def sort(nums: List[int], reverse: bool) -> List[int]:39 quick_sort(nums, 0, len(nums) - 1, reverse)40 return nums41 self._test_sort(sort)42 def test_counting_sort(self):43 def sort(nums: List[int], reverse: bool) -> List[int]:44 return counting_sort(nums, (-10000, 10000), reverse)45 self._test_sort(sort)46 def test_radix_sort(self):47 self._test_sort(radix_sort)48 def test_bucket_sort(self):49 def sort(nums: List[int], reverse: bool) -> List[int]:50 return bucket_sort(nums, (-10000, 10000), reverse)51 self._test_sort(sort)52 53if __name__ == '__main__':...
const_sort_methods.py
Source:const_sort_methods.py
1__author__ = 'bromix'2_xbmc = True3try:4 from xbmcplugin import *5except:6 _xbmc = False7 _count = 08 pass9def _const(name):10 if _xbmc:11 return eval(name)12 else:13 global _count14 _count += 115 return _count16 pass17ALBUM = _const('SORT_METHOD_ALBUM')18ALBUM_IGNORE_THE = _const('SORT_METHOD_ALBUM_IGNORE_THE')19ARTIST = _const('SORT_METHOD_ARTIST')20ARTIST_IGNORE_THE = _const('SORT_METHOD_ARTIST_IGNORE_THE')21BIT_RATE = _const('SORT_METHOD_BITRATE')22# CHANNEL = _const('SORT_METHOD_CHANNEL')23# COUNTRY = _const('SORT_METHOD_COUNTRY')24DATE = _const('SORT_METHOD_DATE')25# DATE_ADDED = _const('SORT_METHOD_DATEADDED')26# DATE_TAKEN = _const('SORT_METHOD_DATE_TAKEN')27DRIVE_TYPE = _const('SORT_METHOD_DRIVE_TYPE')28DURATION = _const('SORT_METHOD_DURATION')29EPISODE = _const('SORT_METHOD_EPISODE')30FILE = _const('SORT_METHOD_FILE')31# FULL_PATH = _const('SORT_METHOD_FULLPATH')32GENRE = _const('SORT_METHOD_GENRE')33LABEL = _const('SORT_METHOD_LABEL')34# LABEL_IGNORE_FOLDERS = _const('SORT_METHOD_LABEL_IGNORE_FOLDERS')35LABEL_IGNORE_THE = _const('SORT_METHOD_LABEL_IGNORE_THE')36# LAST_PLAYED = _const('SORT_METHOD_LASTPLAYED')37LISTENERS = _const('SORT_METHOD_LISTENERS')38MPAA_RATING = _const('SORT_METHOD_MPAA_RATING')39NONE = _const('SORT_METHOD_NONE')40# PLAY_COUNT = _const('SORT_METHOD_PLAYCOUNT')41PLAYLIST_ORDER = _const('SORT_METHOD_PLAYLIST_ORDER')42PRODUCTION_CODE = _const('SORT_METHOD_PRODUCTIONCODE')43PROGRAM_COUNT = _const('SORT_METHOD_PROGRAM_COUNT')44SIZE = _const('SORT_METHOD_SIZE')45SONG_RATING = _const('SORT_METHOD_SONG_RATING')46STUDIO = _const('SORT_METHOD_STUDIO')47STUDIO_IGNORE_THE = _const('SORT_METHOD_STUDIO_IGNORE_THE')48TITLE = _const('SORT_METHOD_TITLE')49TITLE_IGNORE_THE = _const('SORT_METHOD_TITLE_IGNORE_THE')50TRACK_NUMBER = _const('SORT_METHOD_TRACKNUM')51UNSORTED = _const('SORT_METHOD_UNSORTED')52VIDEO_RATING = _const('SORT_METHOD_VIDEO_RATING')53VIDEO_RUNTIME = _const('SORT_METHOD_VIDEO_RUNTIME')54VIDEO_SORT_TITLE = _const('SORT_METHOD_VIDEO_SORT_TITLE')55VIDEO_SORT_TITLE_IGNORE_THE = _const('SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE')56VIDEO_TITLE = _const('SORT_METHOD_VIDEO_TITLE')...
Using AI Code Generation
1var BestMatch = require('./BestMatch.js');2var bm = new BestMatch();3bm.add('test');4bm.add('test2');5bm.add('test3');6bm.add('test4');7bm.add('test5');8bm.add('test6');9bm.add('test7');10bm.add('test8');11bm.add('test9');12bm.add('test10');13bm.add('test11');14bm.add('test12');15bm.add('test13');16bm.add('test14');17bm.add('test15');18bm.add('test16');19bm.add('test17');20bm.add('test18');21bm.add('test19');22bm.add('test20');23bm.add('test21');24bm.add('test22');25bm.add('test23');26bm.add('test24');27bm.add('test25');28bm.add('test26');29bm.add('test27');30bm.add('test28');31bm.add('test29');32bm.add('test30');33bm.add('test31');34bm.add('test32');35bm.add('test33');36bm.add('test34');37bm.add('test35');38bm.add('test36');39bm.add('test37');40bm.add('test38');41bm.add('test39');42bm.add('test40');43bm.add('test41');44bm.add('test42');45bm.add('test43');46bm.add('test44');47bm.add('test45');48bm.add('test46');49bm.add('test47');50bm.add('test48');51bm.add('test49');52bm.add('test50');53bm.add('test51');54bm.add('test52');55bm.add('test53');56bm.add('test54');57bm.add('test55');58bm.add('test56');59bm.add('test57');60bm.add('test58');61bm.add('test59');62bm.add('test60');63bm.add('test61');64bm.add('test62');65bm.add('test63');66bm.add('test64');67bm.add('test65');68bm.add('test66');69bm.add('test67');70bm.add('test68');71bm.add('test69');72bm.add('test70');73bm.add('test71');74bm.add('test72');75bm.add('test73');76bm.add('test74');77bm.add('test75');78bm.add('test76');79bm.add('test77');80bm.add('test78');81bm.add('test79');82bm.add('test80');
Using AI Code Generation
1var BestFit = require('./BestFit.js');2var bf = new BestFit();3bf.add(1, 1);4bf.add(2, 2);5bf.add(3, 3);6bf.add(4, 4);7bf.add(5, 5);8bf.add(6, 6);9bf.add(7, 7);10bf.add(8, 8);11bf.add(9, 9);12bf.add(10, 10);13bf.add(11, 11);14bf.add(12, 12);15bf.add(13, 13);16bf.add(14, 14);17bf.add(15, 15);18bf.add(16, 16);19bf.add(17, 17);20bf.add(18, 18);21bf.add(19, 19);22bf.add(20, 20);23bf.add(21, 21);24bf.add(22, 22);25bf.add(23, 23);26bf.add(24, 24);27bf.add(25, 25);28bf.add(26, 26);29bf.add(27, 27);30bf.add(28, 28);31bf.add(29, 29);32bf.add(30, 30);33bf.add(31, 31);34bf.add(32, 32);35bf.add(33, 33);36bf.add(34, 34);37bf.add(35, 35);38bf.add(36, 36);39bf.add(37, 37);40bf.add(38, 38);41bf.add(39, 39);42bf.add(40, 40);43bf.add(41, 41);44bf.add(42, 42);45bf.add(43, 43);46bf.add(44, 44);47bf.add(45, 45);48bf.add(46, 46);49bf.add(47, 47);50bf.add(48, 48);51bf.add(49, 49);52bf.add(50, 50);53bf.add(51, 51);54bf.add(52, 52);55bf.add(53, 53);56bf.add(54, 54);57bf.add(55, 55);58bf.add(56, 56);59bf.add(57, 57);60bf.add(58, 58);61bf.add(59, 59);62bf.add(60, 60);
Using AI Code Generation
1var BestMatch = require('./BestMatch.js');2var bestMatch = new BestMatch();3var result = bestMatch.sort(['a','b','c','d','e','f','g'], ['a','b','c','d','e','f','g']);4console.log(result);5var BestMatch = function() {6 this.sort = function(array1, array2) {7 var result = [];8 for(var i = 0; i < array2.length; i++) {9 var index = array1.indexOf(array2[i]);10 if(index > -1) {11 result.push(array1.splice(index, 1)[0]);12 }13 }14 return result.concat(array1);15 }16}17module.exports = BestMatch;18Recommended Posts: BestMatch Sort | Set 2 (Using Merge Sort)19BestMatch Sort | Set 3 (Using Quick Sort)20BestMatch Sort | Set 4 (Using Heap Sort)21BestMatch Sort | Set 5 (Using Counting Sort)22BestMatch Sort | Set 6 (Using Radix Sort)23BestMatch Sort | Set 7 (Using Bucket Sort)24BestMatch Sort | Set 8 (Using Shell Sort)25BestMatch Sort | Set 9 (Using Comb Sort)26BestMatch Sort | Set 10 (Using Cycle Sort)27BestMatch Sort | Set 11 (Using Pigeonhole Sort)28BestMatch Sort | Set 12 (Using Bitonic Sort)29BestMatch Sort | Set 13 (Using Pancake Sort)30BestMatch Sort | Set 14 (Using Bogo Sort)31BestMatch Sort | Set 15 (Using Stooge Sort)32BestMatch Sort | Set 16 (Using Tree Sort)33BestMatch Sort | Set 17 (Using Library Sort)34BestMatch Sort | Set 18 (Using Strand Sort)35BestMatch Sort | Set 19 (Using Cube Sort)36BestMatch Sort | Set 20 (Using Flash Sort)37BestMatch Sort | Set 21 (Using Gnome Sort)
Using AI Code Generation
1var BestMatch = require('./best_match.js');2var bestMatch = new BestMatch();3bestMatch.add('cat', 'feline animal');4bestMatch.add('dog', 'canine animal');5bestMatch.add('fish', 'swimming animal');6bestMatch.add('cow', 'mooing animal');7bestMatch.add('horse', 'neighing animal');8bestMatch.add('donkey', 'braying animal');9bestMatch.add('monkey', 'climbing animal');10bestMatch.add('lion', 'king of the jungle');11bestMatch.add('tiger', 'striped animal');12bestMatch.add('elephant', 'big animal');13bestMatch.add('giraffe', 'long necked animal');14bestMatch.add('zebra', 'black and white animal');15bestMatch.add('penguin', 'black and white bird');16bestMatch.add('duck', 'swimming bird');17bestMatch.add('goose', 'honking bird');18bestMatch.add('jaguar', 'big cat');19bestMatch.add('cheetah', 'fast cat');20bestMatch.add('leopard', 'spots cat');21bestMatch.add('panther', 'black cat');22bestMatch.add('bear', 'big furry animal');23bestMatch.add('wolf', 'big dog');24bestMatch.add('hyena', 'laughing dog');25bestMatch.add('rhinoceros', 'big horn animal');26bestMatch.add('hippopotamus', 'big water animal');27bestMatch.add('gazelle', 'fast running animal');28bestMatch.add('antelope', 'fast running animal');29bestMatch.add('kangaroo', 'big hopping animal');30bestMatch.add('emu', 'big flightless bird');31bestMatch.add('ostrich', 'big flightless bird');32bestMatch.add('chicken', 'clucking bird');33bestMatch.add('turkey', 'big bird');34bestMatch.add('sparrow', 'small bird');35bestMatch.add('seagull', 'flying bird');36bestMatch.add('pelican', 'flying bird');37bestMatch.add('dolphin', 'swimming mammal');38bestMatch.add('whale', 'big mammal');39bestMatch.add('shark', 'big fish');40bestMatch.add('parrot', 'flying bird');41bestMatch.add('pigeon', 'flying bird');42bestMatch.add('owl',
Using AI Code Generation
1var BestMatch = require('bestmatch');2var input = "test";3var list = ["test1", "test2", "test3"];4var bm = new BestMatch(list);5var result = bm.sort(input);6console.log(result);7var BestMatch = require('bestmatch');8var input = "test";9var list = ["test1", "test2", "test3"];10var bm = new BestMatch(list);11var result = bm.sort(input, 2);12console.log(result);13var BestMatch = require('bestmatch');14var input = "test";15var list = ["test1", "test2", "test3"];16var bm = new BestMatch(list);17var result = bm.sort(input, 1, true);18console.log(result);19var BestMatch = require('bestmatch');20var input = "test";21var list = ["test1", "test2", "test3"];22var bm = new BestMatch(list);23var result = bm.sort(input, 2, true);24console.log(result);25var BestMatch = require('bestmatch');26var input = "test";27var list = ["test1", "test2", "test3"];28var bm = new BestMatch(list);29var result = bm.sort(input, 2, true, 0.6);30console.log(result);31var BestMatch = require('bestmatch');32var input = "test";33var list = ["test1", "test2", "test3"];34var bm = new BestMatch(list);35var result = bm.sort(input, 2, true, 0.6, 0.2);36console.log(result);
Using AI Code Generation
1var arr = [1,2,3,4,5,6,7,8,9,10];2function sort(){3 arr.sort(function(a,b){4 return a - b;5 });6 console.log(arr);7}8sort();9var arr = [1,2,3,4,5,6,7,8,9,10];10function reverse(){11 arr.reverse();12 console.log(arr);13}14reverse();15var arr1 = [1,2,3,4,5,6,7,8,9,10];16var arr2 = [1,2,3,4,5,6,7,8,9,10];17function concat(){18 var arr3 = arr1.concat(arr2);19 console.log(arr3);20}21concat();22var arr = [1,2,3,4,5,6,7,8,9,10];23function splice(){24 arr.splice(1,3);25 console.log(arr);26}27splice();28var arr = [1,2,3,4,5,6,7,8,9,10];29function slice(){30 var arr2 = arr.slice(1,3);31 console.log(arr2);32}33slice();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!