---
name: "SDL_CompareCallback_r"
section: "3type"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_CompareCallback_r"
---

# SDL\_CompareCallback\_r(3type)

A callback used with SDL sorting and binary search functions.

## NAME

SDL\_CompareCallback\_r - A callback used with SDL sorting and binary search functions.

## HEADER FILE

Defined in SDL3/SDL\_stdinc.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**typedef int (SDLCALL \*SDL\_CompareCallback\_r)(void \*userdata, const void \*a, const void \*b);**

## FUNCTION PARAMETERS

- *userdata*

  the **userdata** pointer passed to the sort function.

- *a*

  a pointer to the first element being compared.

- *b*

  a pointer to the second element being compared.

## RETURN VALUE

Returns -1 if **a** should be sorted before **b** , 1 if **b** should be sorted before **a** , 0 if they are equal. If two elements are equal, their order in the sorted array is undefined.

## AVAILABILITY

This callback is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_qsort\_r**(3)](/SDL_qsort_r/3.md), **•**(3), [**SDL\_bsearch\_r**(3)](/SDL_bsearch_r/3.md)
