GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - bsspirit/ape-algorithm: 算法工具包

BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
README.md
README.md
 
 
bower.json
bower.json
 
 
bucketsort.js
bucketsort.js
 
 
data.js
data.js
 
 
example.js
example.js
 
 
index.js
index.js
 
 
insertionsort.js
insertionsort.js
 
 
linklist.js
linklist.js
 
 
package.json
package.json
 
 
quicksort.js
quicksort.js
 
 
rowcol.js
rowcol.js
 
 

Repository files navigation

APE: 算法工具包

支持普通数组的排序和数组对象的排序。

http://blog.fens.me/algorithm-quicksort-nodejs/

INSTALL

npm install ape-algorithm

API

  • quicksort.js 快速排序
  • insertionsort.js 插入排序
  • bucketsort.js 桶排序
  • data.js 产生随机数据
  • rowcol.js 对JSON数据的行列转换

Demo

example.js

普通数组快速排序

var arr = [23,12,11,43,54,43,2,12,66];
console.log(arr);
console.log(algo.quicksort.sort(arr));
console.log(algo.quicksort.sort(arr,'desc'));

//output
[ 23, 12, 11, 43, 54, 43, 2, 12, 66 ]
[ 2, 11, 12, 12, 23, 43, 43, 54, 66 ]
[ 66, 54, 43, 43, 23, 12, 12, 11, 2 ]

对象数组快速排序,按id值大小排序

var arrObj = [{name:'b',id:12},{name:'c',id:21},{name:'a',id:2}];
console.log(arrObj);
console.log(algo.quicksort.sortObj(arrObj,'id','asc'));
console.log(algo.quicksort.sortObj(arrObj,'id','desc'));

//output
[ { name: 'b', id: 12 },{ name: 'c', id: 21 },{ name: 'a', id: 2 } ]
[ { name: 'a', id: 2 },{ name: 'b', id: 12 },{ name: 'c', id: 21 } ]
[ { name: 'c', id: 21 },{ name: 'b', id: 12 },{ name: 'a', id: 2 } ]

License

MIT

About

算法工具包

Resources

Readme
Activity

Stars

15 stars

Watchers

5 watching

Forks

13 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.