节点:"快速排序"包-排序不是函数


const sort = require('fast-sort');
class sorting {
static async init(input) {
const sorted = await sort([1,4,5,2,3]).asc();
console.log(sorted)
return "hello";

}
}

我正在使用fast-sort包来测试排序。我不断收到TypeError: sort is not a function错误。所以,我在npm软件包页面上尝试了这个例子。我仍然会犯同样的错误。我能在这里做点什么吗?我有点迷路了。

如文档所示,sort是导入对象的属性,而不是整个导入本身。您需要:

const { sort } = require('fast-sort');

最新更新