# sort_get_sessions

- **Language:** C
- **Kind:** function
- **Source:** https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/sort.c#L465
- **Page:** https://libtmux.org/en/tmux/3.7c/reference/c-function-sort_get_sessions/

```c
struct session ** sort_get_sessions(u_int *n, struct sort_criteria *sort_crit)
```

## Parameters

- `n` (`u_int *`)
- `sort_crit` (`struct sort_criteria *`)

## Called by

- [`cmd_list_sessions_exec`](/en/tmux/3.7c/reference/c-function-cmd-list-sessions-c-cmd_list_sessions_exec/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/cmd-list-sessions.c#L75)
- [`format_loop_sessions`](/en/tmux/3.7c/reference/c-function-format-c-format_loop_sessions/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/format.c#L4652)
- [`session_next_session`](/en/tmux/3.7c/reference/c-function-session_next_session/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/session.c#L285)
- [`session_previous_session`](/en/tmux/3.7c/reference/c-function-session_previous_session/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/session.c#L308)
- [`window_tree_build`](/en/tmux/3.7c/reference/c-function-window-tree-c-window_tree_build/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/window-tree.c#L367)

## Calls

- [`sort_qsort`](/en/tmux/3.7c/reference/c-function-sort-c-sort_qsort/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/sort.c#L481)
- [`xreallocarray`](/en/tmux/3.7c/reference/c-function-xreallocarray/) (function) [Call site](https://github.com/tmux/tmux/blob/e476c1230b958df0cb12977517d24b3dc931375b/sort.c#L476)

## Other function references

- [`sort_session_cmp`](/en/tmux/3.7c/reference/c-function-sort-c-sort_session_cmp/) (function)

## Referenced declarations

- [`session`](/en/tmux/3.7c/reference/c-struct-session/) (struct)
- [`sort_criteria`](/en/tmux/3.7c/reference/c-struct-sort_criteria/) (struct)
