Skip to content

Commit ebd7667

Browse files
committed
Implement sort helper function
Introduce 'inorder' function to facilitate sorting operations in both ascending and descending order. Change-Id: Ibe72fc08683c575dd9a608b40f3aad924897819e
1 parent 628403f commit ebd7667

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

queue.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ void q_reverseK(struct list_head *head, int k)
197197
}
198198
}
199199

200+
static inline bool inorder(char *a, char *b, bool descend)
201+
{
202+
int cmp = strcmp(a, b);
203+
return ((cmp < 0) && !descend) || ((cmp > 0) && descend);
204+
}
205+
200206
/* Sort elements of queue in ascending/descending order */
201207
void q_sort(struct list_head *head, bool descend) {}
202208

0 commit comments

Comments
 (0)