mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-11-09 22:08:58 +01:00
✨ Add "sort-array-alphabet" challenge
This commit is contained in:
parent
6a40154d93
commit
565d95079f
11
challenges/sort-array-alphabet/README.md
Normal file
11
challenges/sort-array-alphabet/README.md
Normal file
@ -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.
|
6
challenges/sort-array-alphabet/input-output.json
Normal file
6
challenges/sort-array-alphabet/input-output.json
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"input": [["JavaScript", "Apple", "Hello", "Car", "Orange", "Ice scream"]],
|
||||
"output": ["Apple", "Car", "Hello", "Ice scream", "JavaScript", "Orange"]
|
||||
}
|
||||
]
|
0
challenges/sort-array-alphabet/solutions/.gitkeep
Normal file
0
challenges/sort-array-alphabet/solutions/.gitkeep
Normal file
@ -0,0 +1,4 @@
|
||||
# typescript-easy-sort - sort-array-alphabet
|
||||
|
||||
Programming language : TypeScript
|
||||
Created by [@Divlo](https://github.com/Divlo) at 7 July 2020.
|
@ -0,0 +1,5 @@
|
||||
function solution (stringsArray: string[]) {
|
||||
return stringsArray.sort((a, b) => a.localeCompare(b))
|
||||
}
|
||||
|
||||
export default solution
|
@ -0,0 +1,4 @@
|
||||
# javascript-easy-sort - sort-array-number
|
||||
|
||||
Programming language : JavaScript
|
||||
Created by [@Divlo](https://github.com/Divlo) at 7 July 2020.
|
@ -0,0 +1,5 @@
|
||||
function solution (numbers) {
|
||||
return numbers.sort((a, b) => a - b)
|
||||
}
|
||||
|
||||
module.exports = solution
|
Loading…
Reference in New Issue
Block a user