No description
Find a file
2024-08-14 14:08:05 +08:00
.gitignore Initial commit 2024-08-05 21:02:16 +08:00
index.js feat: add logic 2024-08-05 22:26:53 +08:00
package-lock.json Initial commit 2024-08-05 21:02:16 +08:00
package.json Initial commit 2024-08-05 21:02:16 +08:00
README.md Update README.md 2024-08-14 14:08:05 +08:00

Sort Array By Letter

Question

Sloth Bytes | 2024-07-30

Sort by the Letters
Write a function that sorts each string in a list by the letter in alphabetic ascending order (a-z).

Examples
sort_by_letter(["932c", "832u32", "2344b"])
output = ["2344b", "932c", "832u32"]

sort_by_letter(["99a", "78b", "c2345", "11d"])
output = ["99a", "78b", "c2345", "11d"]

sort_by_letter(["572z", "5y5", "304q2"])
output = ["304q2", "5y5", "572z"]

sort_by_letter([])
output = []

#here's your starting point :)
def sort_by_letter(arr):

Notes
- Each string will only have one (lowercase) letter.
- If given an empty list, return an empty list.

Description

This utility takes a user input of array string number and sort it by the letter of each element. The utility will then display the sorted array.

Table of Contents

Installation

To use the code in this repository, you need to have Node.js installed on your machine. Clone the repository to your local system using the following command:

git clone https://github.com/afiqzudinhadi/sort-by-letters.git

Install the required dependencies by running the following command:

npm install

Usage

  1. Navigate to the repository's root directory.
  2. Open terminal or command prompt.
  3. Run the following command to execute the code:
npm run index
  1. Follow the on-screen instructions to input the array of strings.