Next: , Previous: , Up: Dictionaries   [Contents][Index]


2.6.4 Changing Variable Order

The variables in a dictionary are stored in an array. These functions change the order of a dictionary’s array of variables without changing which variables are in the dictionary.

Function: void dict_reorder_var (struct dictionary *dict, struct variable *var, size_t new_index)

Moves var, which must be in dict, so that it is at position new_index in dict’s array of variables. Other variables in dict, if any, retain their relative positions. new_index must be less than the number of variables in dict.

Function: void dict_reorder_vars (struct dictionary *dict, struct variable *const *new_order, size_t count)

Moves the count variables in new_order to the beginning of dict’s array of variables in the specified order. Other variables in dict, if any, retain their relative positions.

All of the variables in new_order must be in dict. No duplicates are allowed within new_order, which means that count must be no greater than the number of variables in dict.