sx-is-sorted

1.0.2 • Public • Published

sx-is-sorted

介绍

判断number[]数组中元素是由小到大或者是由大到小

安装教程

  1. npm i sx-is-sorted
  2. import sxIsSorted from "sx-is-sorted"

使用说明

import sxIsSorted from "sx-is-sorted";

// 第一个参数number[],第二个参数默认为true,数组中元素是否由小到大

console.log(sxIsSorted([1, 2, 3, 4, 5])); // 返回 true

console.log(sxIsSorted([1, 2, 3, 5, 4])); // 返回 false

// 第一个参数number[],第二个参数为false,数组中元素是否由大到小

console.log(sxIsSorted([5, 4, 3, 2, 1], false)); // 返回 true

console.log(sxIsSorted([4, 5, 3, 2, 1], false)); // 返回 false

Readme

Keywords

Package Sidebar

Install

npm i sx-is-sorted

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

3 kB

Total Files

5

Last publish

Collaborators

  • shi-xi