1
0
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:
Delyan Angelov 2020-10-21 12:57:58 +03:00
parent 02db94c4bc
commit 28d7532fe8

View File

@ -614,7 +614,7 @@ numbers.sort(a > b) // 3, 2, 1
```v ```v
struct User { age int name string } 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.age < b.age) // sort by User.age int field
users.sort(a.name > b.name) // reverse sort by User.name string field users.sort(a.name > b.name) // reverse sort by User.name string field
``` ```