diff --git a/challenges/sort-array-alphabet/README.md b/challenges/sort-array-alphabet/README.md new file mode 100644 index 0000000..45263b4 --- /dev/null +++ b/challenges/sort-array-alphabet/README.md @@ -0,0 +1,11 @@ +# sort-array-alphabet + +Created by [@Divlo](https://github.com/Divlo) at 7 July 2020. + +## Instructions : + +Write a function that should sort the strings of an array in alphabetical order. + +## Examples : + +See the `input-output.json` file for examples of input/output. diff --git a/challenges/sort-array-alphabet/input-output.json b/challenges/sort-array-alphabet/input-output.json new file mode 100644 index 0000000..f8fec1c --- /dev/null +++ b/challenges/sort-array-alphabet/input-output.json @@ -0,0 +1,6 @@ +[ + { + "input": [["JavaScript", "Apple", "Hello", "Car", "Orange", "Ice scream"]], + "output": ["Apple", "Car", "Hello", "Ice scream", "JavaScript", "Orange"] + } +] diff --git a/challenges/sort-array-alphabet/solutions/.gitkeep b/challenges/sort-array-alphabet/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/sort-array-alphabet/solutions/typescript-easy-sort/README.md b/challenges/sort-array-alphabet/solutions/typescript-easy-sort/README.md new file mode 100644 index 0000000..31af4e5 --- /dev/null +++ b/challenges/sort-array-alphabet/solutions/typescript-easy-sort/README.md @@ -0,0 +1,4 @@ +# typescript-easy-sort - sort-array-alphabet + +Programming language : TypeScript +Created by [@Divlo](https://github.com/Divlo) at 7 July 2020. diff --git a/challenges/sort-array-alphabet/solutions/typescript-easy-sort/solution.ts b/challenges/sort-array-alphabet/solutions/typescript-easy-sort/solution.ts new file mode 100644 index 0000000..718456a --- /dev/null +++ b/challenges/sort-array-alphabet/solutions/typescript-easy-sort/solution.ts @@ -0,0 +1,5 @@ +function solution (stringsArray: string[]) { + return stringsArray.sort((a, b) => a.localeCompare(b)) +} + +export default solution diff --git a/challenges/sort-array-number/solutions/javascript-easy-sort/README.md b/challenges/sort-array-number/solutions/javascript-easy-sort/README.md new file mode 100644 index 0000000..3426bd3 --- /dev/null +++ b/challenges/sort-array-number/solutions/javascript-easy-sort/README.md @@ -0,0 +1,4 @@ +# javascript-easy-sort - sort-array-number + +Programming language : JavaScript +Created by [@Divlo](https://github.com/Divlo) at 7 July 2020. diff --git a/challenges/sort-array-number/solutions/javascript-easy-sort/solution.js b/challenges/sort-array-number/solutions/javascript-easy-sort/solution.js new file mode 100644 index 0000000..686db1c --- /dev/null +++ b/challenges/sort-array-number/solutions/javascript-easy-sort/solution.js @@ -0,0 +1,5 @@ +function solution (numbers) { + return numbers.sort((a, b) => a - b) +} + +module.exports = solution