diff --git a/SortStudents.js b/SortStudents.js new file mode 100644 index 0000000..b41a2e3 --- /dev/null +++ b/SortStudents.js @@ -0,0 +1,13 @@ +function sortStudents(students) { + students.sort((a,b) => { + if (a.graduated && !b.graduated) { + return -1; + } + if (b.graduated && !a.graduated) { + return 1; + } + return b.grade - a.grade; + }); +} + +module.exports = sortStudents; diff --git a/StringComp.js b/StringComp.js new file mode 100644 index 0000000..c8908c2 --- /dev/null +++ b/StringComp.js @@ -0,0 +1,11 @@ +function sortStringsUp(array) { + array.sort((a,b) => { + return a.localeCompare(b); + }); +} + +let array = {a,b,b,a,a,b,}; + +console.log(sortStringsUp(array)); + +module.exports = sortStringsUp; diff --git a/StringsAscending.js b/StringsAscending.js new file mode 100644 index 0000000..2d15248 --- /dev/null +++ b/StringsAscending.js @@ -0,0 +1,7 @@ +function sortStringsUp(array) { + array.sort((a,b) => { + return a.localeCompare(b); + }); +} + +module.exports = sortStringsUp; diff --git a/arraysort.js b/arraysort.js new file mode 100644 index 0000000..b0366e2 --- /dev/null +++ b/arraysort.js @@ -0,0 +1,9 @@ +function sortUp(array) { + array.sort((a,b) => a-b); +} + +let array = {3,4,51,2,3}; + +sortUp(array); + +module.exports = sortUp; diff --git a/sortDownArr.js b/sortDownArr.js new file mode 100644 index 0000000..6c79432 --- /dev/null +++ b/sortDownArr.js @@ -0,0 +1,12 @@ +function sortDown(array) { + return array.sort((a,b) => { + return b-a; + + }); +} + +let array = {3,2,4,1}; + +sortDown(array); + +module.exports = sortDown;