public/subjects/shoppinglistsort
Tiago Collot c0792d627f docs(shoppinglistsort): fix instructions 2022-10-31 16:47:37 +00:00
..
README.md docs(shoppinglistsort): fix instructions 2022-10-31 16:47:37 +00:00

README.md

shoppinglistsort

Instructions

You were sent to the supermarket with a shopping list. To make your shopping faster, write a function ShoppingListSort() that takes a slice of strings and sorts it, according to the string length, returning a slice in which the strings appear in ascending order.

  • Strings within the input slice must be of different lengths.

Expected function

func ShoppingListSort(slice []string) []string {

}

Usage

Here is a possible program to test your function:

package main

import (
	"fmt"
	"piscine"
)

func main() {
	slice := []string{"Pineapple", "Honey", "Mushroom", "Tea", "Pepper", "Milk"}
	fmt.Println(ShoppingListSort(slice))
}

And its output:

$ go run . | cat -e
[Tea Milk Honey Pepper Mushroom Pineapple]$