Giter VIP home page Giter VIP logo

sort.js's Introduction

sort.js

JavaScript to achieve the ten common sorting algorithm library

这个小库是对常见的十大排序算法的一个基本汇总,建议读者直接看源码|看源码|看源码。别怕,我注释十分清晰,你要是还看不懂,给我说,我给你拆分成模块。看你能看懂不。

对于实在不能理解的同学,听我的吧!!!这是死东西,那你就--背下来|背下来|背下来。就说三遍,背完之后,还不能理解,那我也不能理解了。(牢记:千万别死背-边背边想边理解)。

简单的使用和测试


在命名空间PAS下使用

[
 'bubble',
 'insert',
 'quick',
 'selection',
 'merge',
 'shell',
 'heap',
 'radix',
 'bucket',
 'count'
].forEach(function(func) {
  var arr = [1,2,3,5,6,3,1,4];
  console.log(PAS[func](arr))
});

//上面输出的结果统一为:`[ 1, 1, 2, 3, 3, 4, 5, 6 ]`

直接当做数组的方法调用

[
 'bubble',
 'insert',
 'quick',
 'selection',
 'merge',
 'shell',
 'heap',
 'radix',
 'bucket',
 'count'
].forEach(function(func) {
	var arr = [1,2,3,5,6,3,1,4];
	console.log(arr[func]())
})

//上面输出的结果统一为:`[ 1, 1, 2, 3, 3, 4, 5, 6 ]`

喜欢的,觉得对你有帮助的,给个star,交个朋友吧!!!

sort.js's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.