You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
803 B

## sortlist
### Instructions
Write the following functions and its struture :
```go
type Node struct {
data int
next *node
}
func SortList(l *node, func cmp(a,b int) bool) *node{
}
```
6 years ago
This function must sort the list given as a parameter using the function `cmp` to select the order to apply. It must then return a pointer to the first element of the sorted list.
- Duplications must remain.
6 years ago
- Inputs will always be consistent.
6 years ago
- The type `Node` must be used.
6 years ago
- Functions passed as `cmp` will always return a boolean. If `a` and `b` are in the right order it returns `true`, otherwise it returns `false`.
6 years ago
- For example; the following function used as cmp will sort the list in ascending order :
```go
func ascending(a, b int) {
if a <= b {
return true
} else {
return false
}
}
6 years ago
```