@@ -328,6 +328,21 @@ STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t valu
328
328
return mp_const_none ;
329
329
}
330
330
331
+ //| def sort(self, key: function, reverse: bool) -> None:
332
+ //| """Sort the members of the group."""
333
+ //| ...
334
+ //|
335
+ STATIC mp_obj_t displayio_group_obj_sort (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
336
+ displayio_group_t * self = native_group (pos_args [0 ]);
337
+ mp_obj_t * args = m_new (mp_obj_t , n_args );
338
+ for (size_t i = 1 ; i < n_args ; ++ i ) {
339
+ args [i ] = pos_args [i ];
340
+ }
341
+ args [0 ] = self -> members ;
342
+ return mp_obj_list_sort (n_args , pos_args , kw_args );
343
+ }
344
+ MP_DEFINE_CONST_FUN_OBJ_KW (displayio_group_sort_obj , 1 , displayio_group_obj_sort );
345
+
331
346
STATIC const mp_rom_map_elem_t displayio_group_locals_dict_table [] = {
332
347
{ MP_ROM_QSTR (MP_QSTR_hidden ), MP_ROM_PTR (& displayio_group_hidden_obj ) },
333
348
{ MP_ROM_QSTR (MP_QSTR_scale ), MP_ROM_PTR (& displayio_group_scale_obj ) },
@@ -338,6 +353,7 @@ STATIC const mp_rom_map_elem_t displayio_group_locals_dict_table[] = {
338
353
{ MP_ROM_QSTR (MP_QSTR_index ), MP_ROM_PTR (& displayio_group_index_obj ) },
339
354
{ MP_ROM_QSTR (MP_QSTR_pop ), MP_ROM_PTR (& displayio_group_pop_obj ) },
340
355
{ MP_ROM_QSTR (MP_QSTR_remove ), MP_ROM_PTR (& displayio_group_remove_obj ) },
356
+ { MP_ROM_QSTR (MP_QSTR_sort ), MP_ROM_PTR (& displayio_group_sort_obj ) },
341
357
};
342
358
STATIC MP_DEFINE_CONST_DICT (displayio_group_locals_dict , displayio_group_locals_dict_table );
343
359
0 commit comments