The sorted list library provides an implementation of the ordered list. Access to the list is not protected. The user function is used for comparing items.
To create a sorted list instance, use the NRF_SORTLIST_DEF macro and provide the identifier and the compare function.
Items which can be put into the list must contain the nrf_sortlist_item_t element. CONTAINER_OF() macro should be used to ensure that the nrf_sortlist_item_t element is correctly used.
Sample code for element structure definition:
Example of the compare function:
Example of sorted list instance definition:
Example of adding and poping an element into/from the list: