Skip to content

Commit a77e70c

Browse files
Merge pull request #10 from alexanderywang/sort
Sort, closes #1
2 parents bce777f + 77c245c commit a77e70c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/sort.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11

2+
/**
3+
* A function to sort numbers in an array in ascending order
4+
* @param array - an array
5+
* @return - a new sorted array
6+
*/
7+
const sort = array => {
8+
const copiedArray = array.slice()
9+
return copiedArray.sort((a,b) => a-b)
10+
}
11+
12+
module.exports = sort;

src/tests/sort.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ const expect = require("chai").expect;
22
const sort = require("../sort");
33

44
describe("sort", () => {
5-
xit("sorts numbers in ascending order", () => {
5+
it("sorts numbers in ascending order", () => {
66
const myArr = [6, 4, 5, 2, 3, 1];
77
const sortedArr = sort(myArr);
88
expect(sortedArr).to.deep.equal([1, 2, 3, 4, 5, 6]);
99
});
10-
xit("does not mutate the array", () => {
10+
it("does not mutate the array", () => {
1111
const myArr = [6, 4, 5, 2, 3, 1];
1212
const sortedArr = sort(myArr);
1313
expect(myArr).to.deep.equal([6, 4, 5, 2, 3, 1]);

0 commit comments

Comments
 (0)