Signed-off-by: Shakur Shams Mullick <shakursmullick@xxxxxxxxx> --- libsmartcols/src/table_print.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c index 24b73f9..fed0305 100644 --- a/libsmartcols/src/table_print.c +++ b/libsmartcols/src/table_print.c @@ -694,7 +694,28 @@ static size_t strlen_line(struct libscols_line *ln) return sz; } +int comparison_func(struct list_head *a, struct list_head *b, void *data) +{ + struct libscols_column *cl; + struct libscols_line *ra, *rb; + struct libscols_cell *ca, *cb; + + cl = (struct libscols_column *)(data); + + ra = list_entry(a, struct libscols_line, ln_lines); + rb = list_entry(b, struct libscols_line, ln_lines); + + ca = scols_line_get_cell(ra, cl->seqnum); + cb = scols_line_get_cell(rb, cl->seqnum); + + return cl->compare_data(ca, cb, NULL); +} +void scols_sort_table(struct libscols_table *tb, struct libscols_column *cl) +{ + assert(tb); + list_sort(&tb->tb_lines, comparison_func, cl); +} /** * scols_print_table: -- 1.8.3.2 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html