From: Karel Zak <kzak@redhat.com>
To: Shakur Shams Mullick <shakursmullick@gmail.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH v2 7/8] libsmartcols/src/table_print.c: sort the list before printing
Date: Mon, 12 May 2014 14:43:47 +0200 [thread overview]
Message-ID: <20140512124347.GK8951@x2.net.home> (raw)
In-Reply-To: <1399796438-5495-7-git-send-email-shakursmullick@gmail.com>
On Sun, May 11, 2014 at 02:20:37PM +0600, Shakur Shams Mullick wrote:
> +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->compar(ca, cb, NULL);
^^^^^
I guess that we need something like cl->compare_data.
> + cl = scols_table_get_key_column(tb);
Do we really need table->cl_key? Maybe it would be better to add
scols_sort_table(tb, cl)
and keep control of the sort column in the applications. It will
also allow to sort table by more columns.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2014-05-12 12:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-11 8:20 [PATCH v2 1/8] libsmartcols/src/libsmartcols.h.in: add library functions Shakur Shams Mullick
2014-05-11 8:20 ` [PATCH v2 2/8] libsmartcols/src/libsmartcols.sym: add symbols Shakur Shams Mullick
2014-05-11 8:20 ` [PATCH v2 3/8] libsmartcols/src/smartcolsP.h: add new field to struct libscols_table Shakur Shams Mullick
2014-05-11 8:20 ` [PATCH 4/8] libsmartcols/src/cell.c: add two functions to compare number and string cells Shakur Shams Mullick
2014-05-12 12:37 ` Karel Zak
2014-05-11 8:20 ` [PATCH 5/8] libsmartcols/src/column.c: add function to set comparison function scols_column_set_sortcmp() sets the cell comparison function to use Shakur Shams Mullick
2014-05-11 8:20 ` [PATCH v2 6/8] libsmartcols/src/table.c: set and get key column to use for sorting scols_table_set_key_column() sets the column to use scols_table_get_key_column() returns the column being used Shakur Shams Mullick
2014-05-11 8:20 ` [PATCH v2 7/8] libsmartcols/src/table_print.c: sort the list before printing Shakur Shams Mullick
2014-05-12 12:43 ` Karel Zak [this message]
2014-05-12 17:22 ` shams
2014-05-11 8:20 ` [PATCH v2 8/8] misc-utils/lsblk.c: adds sorting support for lsblk Shakur Shams Mullick
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140512124347.GK8951@x2.net.home \
--to=kzak@redhat.com \
--cc=shakursmullick@gmail.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox