Posted 9 years ago by Daniel
Avatar

Hi, and thank you for the great app!

I'd be happy to see a function to sort selected lines of text. Even better would be a function to sort the lines by field, where field separator is whatever tab-character is set to.

I'm looking forward to hear what you think about this idea. Thanks!

Comments (4)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

Thanks for the suggestion.  Can you provide more info about the more complex sorting idea you mentioned, how it would work in detail and with an example?


Actipro Software Support

Posted 9 years ago by Daniel
Avatar

Hi,

For example, consider these alphasorted lines:

char	b;
int	a;

Type is 1st field and identifier is 2nd, separated by tab. If I want these sorted by identifier, result would be:

int	a;
char	b;

Lines without enough fields or empty lines can be collated first. If I want these sorted by 2nd field:

char	b;
label_y:
<NL>
int	a;
label_x:

Result would be:

<NL>
label_x:
label_y:
int	a;
char	b;

The above is ofcourse somewhat nonsensical. Here is intended usage scenario:

void	unmark_line_node(line_t *);
void	unset_active_nodes(line_t *, line_t *);
long	write_stream(FILE *, long, long);
int	put_stream_line(FILE *, const char *, int);
int	get_tty_line(void);
void	handle_hup(int);
int	append_lines(long);
int	cbc_encode(unsigned char *, int, FILE *);
long	get_line_node_addr(line_t *);
long	write_file(char *, const char *, long, long);
long	get_marked_node_addr(int);
void	add_line_node(line_t *);
int	apply_subst_template(const char *, regmatch_t *, int, int);
int	build_active_list(int);
long	get_matching_node_addr(pattern_t *, int);
int	cbc_decode(unsigned char *, FILE *);
int	put_tty_line(const char *, int, long, int);

Result would be, by 2nd field sort:

void	add_line_node(line_t *);
int	append_lines(long);
int	apply_subst_template(const char *, regmatch_t *, int, int);
int	build_active_list(int);
int	cbc_decode(unsigned char *, FILE *);
int	cbc_encode(unsigned char *, int, FILE *);
long	get_line_node_addr(line_t *);
long	get_marked_node_addr(int);
long	get_matching_node_addr(pattern_t *, int);
int	get_tty_line(void);
void	handle_hup(int);
int	put_stream_line(FILE *, const char *, int);
int	put_tty_line(const char *, int, long, int);
void	unmark_line_node(line_t *);
void	unset_active_nodes(line_t *, line_t *);
long	write_file(char *, const char *, long, long);
long	write_stream(FILE *, long, long);

Now prototypes are sorted by function name. Way more clean :-)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

Thanks for the example.  Have you seen any editors that have that kind of sorting functionality in it?  I was peeking at a couple but only saw things like alpha, alpha (case sensitive), reverse, shuffle, etc.  All of those operate on the entire line.  The thing that's tricky about what you show here is that languages might also have things like modifiers in place, as in this C# example:

internal    int    foo;
            string bar;
const       int    foo2 = 3; 

That makes it difficult to support non-full-line sorting scenarios. 


Actipro Software Support

Posted 9 years ago by Daniel
Avatar

Hi,

Thanks for swift reply. I'm not aware of any editor that does it natively. Easiest way that I know how to do it is to filter the lines through a shell command. You're right about the support for this. It's probably more trouble than it's worth.

However, I hope you will consider support for alphasort. Just about any good-quality editor is able to do that ;-)

The latest build of this product (v4.2.42) was released 3 years ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.