jherax / array-sort-by Goto Github PK
View Code? Open in Web Editor NEWPowerful mechanism to sort arrays or array of objects by one or more properties. You can also specify a custom comparer function.
License: ISC License
Powerful mechanism to sort arrays or array of objects by one or more properties. You can also specify a custom comparer function.
License: ISC License
Hello!
I was trying to use your module to sort in descending order my leaderboard in quick.db, but I couldn't. It gives me this error:
Why?
Here is my leaderboard code:
`const Discord = require("discord.js");
const db = require('quick.db');
var sortBy = require('array-sort-by');
var currencyFormatter = require('currency-formatter'); //For currency
var fs = require('fs'); //FileSystem
exports.run = async (bot, message, args) => {
const resp = await db.startsWith('moons', { sort: '.data'});
resp.length = 10;
let finalOutput = ' ';
for (var i in resp) {
var us = bot.users.get(resp[i].ID.split("")[1])
//moons${us.id}
let Moonsdisplay;
let TotalMoons;
let moons = await db.fetch(moons_${us.id}
)
if (moons === null) db.set(moons_${us.id}
, 0);
else TotalMoons = moons;
if (TotalMoons === undefined) TotalMoons = 0;
let amount = parseInt(args.join(' '));
if (TotalMoons > 1000000) { Moonsdisplay = 'Infinitas' } else {Moonsdisplay = TotalMoons}
var usermoons = Moonsdisplay;
finalOutput += **${bot.users.get(resp[i].ID.split("_")[1]).tag}**
+ ' ' + usermoons + moons \n
; // - Moons: ${resp[i].data}
console.log(finalOutput)
var arr = ['teste', 'do', 'caralho']
var msgtosend = await sortBy(finalOutput, item => 'desc:' + item)
}
message.channel.send({
embed: {
"description": msgtosend,
"title": 'Top de Moons',
"color": 16777215
}
})
}
module.exports.command = {
name: 'topmoons',
aliases: ['leaderboard'],
description: 'Veja os mais ricos do servidor!',
category: "Economia",
usage: 's!topmoons',
enabled: false
}`
Please fix this.
It would be nice to add support for TypeScript.
Hi, does it sort dateTime? Is any way to sort it.
It will be useful to allow register additional accented characters, and maps the equivalent value in the range [A-Z] in order to support sorting for other languages.
When you try order an array of non ASCII characters like this ['á', 'e', 'ú', 'c']
, you will obtain a strange result: ["c", "e", "á", "ú"]
.
Expected: ["á", "c", "e", "ú"]
It would be nice to add support for TypeScript.
For ie it not work right?
import sortBy from 'array-sort-by'; iam using es2015 syntax to import js files
error: bundling: ReferenceError: Unknown plugin "babel-plugin-add-module-exports" specified in "/Users/jagadeesh/Projects/working/xxx/Presentation/yyyy/node_modules/array-sort-by/package.json" at 0, attempted to resolve relative to "/Users/jagadeesh/Projects/working/xxx/Presentation/yyyy/node_modules/array-sort-by"
at /Users/jagadeesh/Projects/working/xxx/Presentation/yyyy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
at Array.map (native)
at Function.normalisePlugins (/Users/jagadeesh/Projects/working/xxx/Presentation/yyyy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/Users/jagadeesh/Projects/working/xxxx/Presentation/yyyy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/Users/jagadeesh/Projects/working/xxxx/Presentation/yyyy/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/Users/jagadeesh/Projects/working/xxx/Presentation/yyyy/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/Users/jagadeesh/Projects/working/xxxx/Presentation/yyyy/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/Users/jagadeesh/Projects/working/xxx/Presentation/yyyy/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at Object.transform (/Users/jagadeesh/Projects/working/iCommandV3/Presentation/yyyy/node_modules/react-native/packager/transformer.js:109:25)
When using webpack + babel to build my simple app this error message is shown on compile...
ERROR in ./node_modules/array-sort-by/src/sort-by.js
Module build failed: ReferenceError: Unknown plugin "babel-plugin-add-module-exports" specified
in "/project/node_modules/array-sort-by/package.json"
at 0, attempted to resolve relative to "/project/node_modules/array-sort-by"
at /project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
at Array.map (native)
at Function.normalisePlugins (/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/project/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/project/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/project/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/project/node_modules/babel-loader/lib/index.js:50:20)
at Object.module.exports (/project/node_modules/babel-loader/lib/index.js:175:20)
@ ./src/App.js
@ ./src/index.js
@ multi babel-polyfill ./src/index.js
Should the 'array-sort-by' package.json be including the babel plugin ???
I have a number of React Jest / Enzyme tests which test a component that uses array-sort-by
i include the following (naming my default import as arraySort)
// make sorting by types and nested object easier
import arraySort from 'array-sort-by';
and when i have version 1.1.0 installed everything works as expected and the test all pass. However when I upgrade to version 1.2.0 then the test fail to run with the error message above....
The code still compiles but fails to run with a
(0 , _arraySortBy.sortBy) is not a function
What do I need to import in order to get version 1.2.0 importing / running - as before ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.