Comparing version 1.13.8 to 1.14.8
@@ -18,2 +18,3 @@ export declare namespace arrayUtils { | ||
function quickSort<T>(arr: T[]): T[]; | ||
function quickSortDescending<T>(arr: T[]): T[]; | ||
function arrPush<T>(arr: T[], target: T): T[]; | ||
@@ -20,0 +21,0 @@ function arrUnshift<T>(arr: T[], target: T): T[]; |
@@ -63,2 +63,20 @@ "use strict"; | ||
arrayUtils.quickSort = quickSort; | ||
function quickSortDescending(arr) { | ||
if (arr.length <= 1) { | ||
return arr; | ||
} | ||
const pivot = arr[0]; | ||
const left = []; | ||
const right = []; | ||
for (let i = 1; i < arr.length; i++) { | ||
if (arr[i] >= pivot) { // Modified condition for descending order | ||
left.push(arr[i]); | ||
} | ||
else { | ||
right.push(arr[i]); | ||
} | ||
} | ||
return [...quickSortDescending(left), pivot, ...quickSortDescending(right)]; // Recursively sort left and right arrays | ||
} | ||
arrayUtils.quickSortDescending = quickSortDescending; | ||
function arrPush(arr, target) { | ||
@@ -127,4 +145,4 @@ arr.push(target); | ||
arrayUtils.arrToLowerCase = arrToLowerCase; | ||
// Add more array utility functions here as needed... | ||
// Add more array utility functions here as needed... | ||
})(arrayUtils || (exports.arrayUtils = arrayUtils = {})); | ||
//# sourceMappingURL=arrayUtils.js.map |
{ | ||
"name": "auxin", | ||
"version": "1.13.8", | ||
"version": "1.14.8", | ||
"description": "Auxin is a powerful Node.js utility toolkit that simplifies common tasks, boosting your development productivity.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -61,2 +61,23 @@ export module arrayUtils { | ||
} | ||
export function quickSortDescending<T>(arr: T[]): T[] { | ||
if (arr.length <= 1) { | ||
return arr; | ||
} | ||
const pivot = arr[0]; | ||
const left = []; | ||
const right = []; | ||
for (let i = 1; i < arr.length; i++) { | ||
if (arr[i] >= pivot) { // Modified condition for descending order | ||
left.push(arr[i]); | ||
} else { | ||
right.push(arr[i]); | ||
} | ||
} | ||
return [...quickSortDescending(left), pivot, ...quickSortDescending(right)]; // Recursively sort left and right arrays | ||
} | ||
@@ -129,5 +150,3 @@ export function arrPush<T>(arr: T[], target: T): T[] { | ||
// Add more array utility functions here as needed... | ||
// Add more array utility functions here as needed... | ||
} |
@@ -11,2 +11,12 @@ const { arrayUtils } = require('../dist/arrayUtils'); // Import the array utility functions to be tested | ||
const decarrr = [3, 1, 4, 1, 5, 9, 2, 6, 5]; | ||
const dec = arrayUtils.quickSortDescending(decarrr); | ||
console.log("dec",dec); // Output: [1, 1, 2, 3, 4, 5, 5, 6, 9] | ||
// const desarrr = [5, 2, 8, 1, 9]; | ||
// const sortedDescending = quickSortDescending(desarrr); | ||
// console.log(sortedDescending); // Output: [9, 8, 5, 2, 1] | ||
const pushedArray = arrayUtils.arrPush(arr, 3); | ||
@@ -13,0 +23,0 @@ console.log(pushedArray); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93165
722