mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
docs: make the users.sort example directly runnable
This commit is contained in:
parent
02db94c4bc
commit
28d7532fe8
@ -614,7 +614,7 @@ numbers.sort(a > b) // 3, 2, 1
|
||||
|
||||
```v
|
||||
struct User { age int name string }
|
||||
mut users := [...]
|
||||
mut users := [User{21, 'Bob'}, User{20, 'Zarkon'}, User{25, 'Alice'}]
|
||||
users.sort(a.age < b.age) // sort by User.age int field
|
||||
users.sort(a.name > b.name) // reverse sort by User.name string field
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user