## issorted
### Instructions
Write a function `IsSorted` that returns `true` , if the slice of `int` is sorted, otherwise returns `false` .
The function passed in the parameter returns a positive `int` if `a` (the first argument) is greater than to `b` (the second argument), it returns `0` if they are equal and it returns a negative `int` otherwise.
To do your testing you have to write your own `f` function.
### Expected function
```go
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
func IsSorted(f func(a, b int) int, a []int) bool {
}
```
### Usage
Here is a possible program to test your function (without `f` ):
```go
package main
import (
"fmt"
"piscine"
)
func main() {
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
a1 := []int{0, 1, 2, 3, 4, 5}
a2 := []int{0, 2, 1, 3}
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
result1 := piscine.IsSorted(f, a1)
result2 := piscine.IsSorted(f, a2)
fmt.Println(result1)
fmt.Println(result2)
}
```
And its output :
```console
$ go run .
true
false
$
```
### Notions
- [Function literals ](https://golang.org/ref/spec#Function_literals )
- [Function declaration ](https://golang.org/ref/spec#Function_declarations )
- [Function types ](https://golang.org/ref/spec#Function_types )