Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [sorting]

Use the sorting tag for questions involving arranging things in a defined order: sorting lines alphabetically, bibtex entries by date or author, emails by sender, completion candidates by various criteria, etc.

Filter by
Sorted by
Tagged with
24
votes
4answers
6k views

org: How to sort headings by TODO and then by priority?

I often have a list like this: * Main heading ** TODO [#A] Make world better ** TODO [#B] Make Emacs better ** TODO [#B] Customize emacs ** DONE [#C] some task ** TODO [#A] Launch rocket to mars I ...
10
votes
3answers
483 views

Sort file names (numbered) in dired

When Dired sorts files by name, it sorts in alphabetical order. That's fine with letters; however, when the file names start with numbers, it would be better to sort in numerical value. Example: ...
10
votes
2answers
5k views

Sorting headings in an ORG file

I'm taking notes in a largish org-mode file that has the following structure: * Toto, A Notes about Toto. * Titi, C Notes about Titi. * Tutu, A Notes about Tutu. I'd like to sort the file so that ...
9
votes
1answer
194 views

Sorting lines with accented characters

When sorting the lines by sort-lines the lines beginning with ä comes after the lines starting with z. It would be nice if the lines could be sorted ignoring the accents, Umlauts, etc, like in a ...
8
votes
1answer
785 views

dired - sort and hide by default

More often than not, when I open a dired buffer, I press ( to run dired-hide-details-mode s to rundired-sort-toggle-or-edit What's a good way to have these done automatically every time I open a ...
7
votes
1answer
114 views

How to alphabetize strings with diacritics?

Q: how do I alphabetize strings with diacritics? Problem I have a long list of author names, some of whom have letters with diacritics in their names (e.g., "á" or "é"). I want to sort this list ...
7
votes
2answers
226 views

Change order of symbols for «sort-lines»

I am using «sort-lines» to sort includes in C/C++ files before saving. The problem that arises is that a headers with " symbols sorted higher than ones with < symbols. But I want the reverse. How ...
6
votes
2answers
346 views

How to make private python methods the last company-mode choices?

I'm using emacs with company-mode and I'd like the 'private' methods (method that start with underline) to be shown last, since they are kind of useless for imported libraries in python. See the image:...
5
votes
1answer
894 views

Sorting org-mode org-agenda file

I have an org-mode file in standard agenda format: * Dentist <2015-10-01> * Put up shelves <2015-10-05> I'm just starting to use org-agenda but I still use just that single file a lot ...
5
votes
2answers
348 views

Change field separator for sort-fields

sort-fields and sort-numeric-fields work great; but the field separator is whitespace. I would like to use a different delimiter (e.g.: [colon-char]). I want this feature because I find myself ...
5
votes
1answer
123 views

Sort by a suffix in file names in dired

I would like to sort the dired buffer by a suffix in the file names. For instance, with the following buffer content: /nixos/nix/store: total used in directory 140344 available 17530560 drwxrwxr-t ...
5
votes
2answers
222 views

Find files with find-dired sorting by date and by size

I often use find-dired and find-named-dired. But I wanted to get the results sorted by date and by size. How can I do that?
4
votes
2answers
192 views

Sorting an org-table numerically, ignoring commas (org-table-sort-lines)

I have the following org-table: | Row # | Facility | Recycled Off-site | |-------+--------------------------+-------------------+ | 1 | 1234, 12th st, jamestown | 216,...
4
votes
2answers
119 views

How to sort bash functions alphabetically?

My boss is a bit of a neat freak. He wants the functions in my functions.sh be ordered alphabetically. foo() { echo foo } baa() { echo baa } So baa should appear first in the file. Can emacs ...
4
votes
1answer
122 views

Randomize headers in Org mode

How can I randomize headers in org mode? e.g. If I had a list like this, : * apple 1 * lemon 2 * banana * orange How can I randomize those headers and get lists like these?: * lemon 2 * ...
3
votes
4answers
417 views

Sorting words with hyphens (e.g. in a Lisp mode)

SortWords in the EmacsWiki suggests this function as a way to sort words: (defun sort-words (reverse beg end) "Sort words in region alphabetically, in REVERSE if negative. When prefixed with ...
3
votes
2answers
107 views

sorting paragraphs of a document by paragraph numbers (not lexicographically)

I have a document whose paragraphs start with a number like this: 101 kjwdujd dkjcjiekrd wekdhehwrd kwedhiehrc wekdhchjedc kjdchhedch . 99 dsjcoiedc wdhiwedc wedhiuwhediuhewdkdeh wedghiuwghediughedc ...
3
votes
1answer
69 views

Sort org-agenda items by category

When using the agenda in org-mode to show my daily tasks, there's a bunch of tasks scheduled for that day (or with past deadlines) that appear at the bottom. I'd like these tasks, and only these, to ...
3
votes
1answer
114 views

how to sort describe-variable completion list by recency (or frequency)?

When I run describe-variable, then choose something, I often wind up looking at the same variable again later or next session. However, when I do describe-variable again, the helm list of variables ...
2
votes
2answers
296 views

Sort list by decreasing length of the strings

I have this list: (setq MYLIST '("J. Phys." "New. J. Phys." "J. Phys. Soc. Jap." "Phys. Plasmas")) How can I get a new list ordered by the decreasing ...
2
votes
1answer
81 views

Is there a timsort implementation in Emacs Lisp?

Timsort is the default sort algo of Python and Java and it performs better than mergesort on roughly sorted lists. I could not find any implementation of this in Elisp. How can I find out whether ...
2
votes
1answer
398 views

Reverse suggestions from hippie-expand

I currently have the following settings for hippie-expand in my .emacs file: (setq hippie-expand-try-functions-list '(try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-...
2
votes
2answers
189 views

org-sort-entries recursively

A natural approach to sorting an outline recursively would be the following: (org-map-entries (lambda () (org-sort-entries nil ?f 'my/sort-function) nil 'tree) ...
2
votes
1answer
53 views

is there a way to sort only on second level headlines in org mode?

is there a way to sort only on second level headlines in org mode? i am outlining a novel with top level headline being the chapter number and the second level headline being the timeline of the ...
2
votes
1answer
47 views

Implementing (org-agenda) sort comparison function in terms of presence of list items

I want to implement an org-agenda-cmp-user-defined for use with org-agenda-sorting-strategy and user-defined-up / user-defined-down. In order to do that, I have two lists of tags I need to compare, ...
2
votes
1answer
141 views

How does sorting work within habits?

I think I have a reasonable handle on agenda custom sorting, but I can't figure out how habits sort themselves within that agendas. For a certain agenda view I sort as '(time-up habit-down todo-state-...
2
votes
1answer
387 views

How to sort an association list (alist)?

Is there a way to sort an association list? In my case I would like to sort the alist elements by the values in each list element (represented by the integers in the example below). Example: (setq ...
2
votes
2answers
138 views

How to put buffers named with an asterisk at the end of ido's selection list?

with (ido-switch-buffer), when I type stuff, "*magit: stuff*" comes before Stuff.txt. the sorting seems to be done by recency, rather than the buffer name. more generally, a custom sort function ...
2
votes
1answer
39 views

Getting a sorted window list

(window-list) returns a list of visible windows. Is it possible to get this list sorted from the most recently active window to the least?
2
votes
3answers
123 views

Elisp: sorting SYM VAL pairs in a setq expression

I wrote a rather clunky elisp function to sort the SYM VAL args in a setq expression alphabetically by SYM. For example: (setq c "blah" (setq a 9 b '(more stuff) --> b '(...
2
votes
1answer
166 views

Sort minor-mode-alist alphabetically (in the mode-line) using :lighter

Q: How to sort the minor-mode-alist alphabetically (in the mode-line) using the :lighter as the criteria for alphabetization. Rough draft that does not work: (setq mode-line-format '( (:eval ...
2
votes
0answers
72 views

Dired: manual files sorting for specific directories

I have a directory with many folder. When I open it in dired I see this: bundles ckeditor companies contries failitators induction jquery_update lwt_shared members messages offices ... I often work ...
1
vote
1answer
70 views

Why so strange sort in dired mode?

windows 10, emacs 26.1, dired+ here myfolder in dired mode sort by name (by default): Now I want to sort by date (inverse mode). I press s and here result: why file new.txt is above two dots? The ...
1
vote
1answer
68 views

Sort entire hirearchy in an Org mode buffer

Running Emacs 25.2.2. Consider the following heading hierarchy: * L1 ** C *** 2 *** 1 ** B *** 3 *** 2 I want to sort it to: * L1 ** B *** 1 *** 2 ** C *** 2 ...
1
vote
1answer
224 views

sort lines by regexp

I have a todo list in a text file that I maintain with TaskAgent and emacs. TaskAgent adds trailing text to a line to indicate priority (#!!! represents highest, #! represents low, and no mark is ...
1
vote
1answer
105 views

shuffling the paragraphs in a buffer

Is there a package/function for shuffling the paragraphs in the buffer? (I mean to sort the paragraphs with a random order, not changing the paragraphs, just randomizing their order). Motivation: ...
1
vote
1answer
124 views

Sort Dewey Decimal list?

If I have a list of books' call numbers in Dewey Decimal in a buffer, is this something I could sort with Emacs regex -- or is this an elisp task? For example, 261.1 C87 comes before 261.104 Z99 ...
1
vote
2answers
215 views

Most efficient way of sorting a list

Given a plain list like: - buy tea - call Anna - Reply email to John - pay bill 1 - phone Derick - Reply to grad-pa which you don't want to sort alphabetically, how can you sort it? Things like '...
1
vote
1answer
17 views

Why dired+ not save sort mode?

windows 10, Emacs 26.1, Dired+ Suppose I has 3 files and sort it by name in dired mode. Smt like this: OK. Now I sort it by date, press s Here result: OK. Now I edit file 3.txt and after save ...
1
vote
1answer
47 views

Reorder fields using bibtex-mode

I would like to clean up BibTeX entries so that fields always appear in the same order. For example, I would like the order of fields to always be: author, year, title, journal. So, pressing C-c C-q ...
1
vote
1answer
141 views

wanderlust: default summary sort order?

I would like my all my wanderlust *Summary* buffers to be sorted by "number" in "reverse" order. I know how to manually request a sort, but I want this specified sort order to always be the default ...
1
vote
1answer
730 views

org-agenda-sorting-strategy: items containing no time-of-day specification first

The manual says For the daily/weekly agenda, the items for each day are sorted. The default order is to first collect all items containing an explicit time-of-day specification. 8:30-13:...
1
vote
1answer
196 views

Is there a way to sort buffers alphabetically in speedbar

By default speedbar displays buffers as they are in the buffer list. Is there a way to sort them by their name alphabetically, either automatically or by triggering the sorting?
1
vote
1answer
67 views

Org mode customized alphabetic sorting

The children of a heading at point can be sorted alphabetically with C-c ^ a. Can this sorting method be customized? What I want is to sort Greek words according to their Latin translitteration. For ...
1
vote
0answers
26 views

Sorting org files in Emacs Dired on the basis of the org time stamp in the file itself

Is there a way of sorting org files (.org) in Emacs Dired on the basis of the org time stamp in the file itself. With every org file I create, I insert an org time stamp near the top of the file. This ...
1
vote
1answer
22 views

sort-columns, but with a stable sort

How can I perform the equivalent of M-x sort-columns with a stable sort? For example, let's say my text is: a 99 b 98 b 97 a 96 a 95 b 94 a 93 b 92 c 91 ... And I want to perform a stable sort ...
1
vote
1answer
75 views

Finding next and previous entries in an avl-tree

I am using an avl-tree to maintain a sorted list, e.g.: (require 'avl-tree) (let ((tree (avl-tree-create (lambda (a b) (string-lessp (car a) (car b)))))) (avl-tree-enter tree (cons "b" 0)) (avl-...
1
vote
0answers
46 views

Sort CSS declarations alphanumerically

As per the Google style guide (but this is a generally recognized as good practice) the CSS declarations should be sorted within rules blocks. So given the following code: .ruleOne { width: 40px; ...
1
vote
0answers
46 views

Is it possible to sort todos by completion?

Is it possible to sort todos by completion? * Bar [0%] ** TODO Bar1 ** TODO Bar2 * Foo [100%] ** DONE Foo1 CLOSED: [2017-06-18 So 17:51] ** DONE Foo2 CLOSED: [2017-06-18 So 17:51] * Foo1 [0%] **...
1
vote
0answers
66 views

emacs dired ignores LC_COLLATE=C when using sudo?

My emacs dired changes sort order from ASCII to case-insensitive whenever I view a directory listing under sudo::. Checking getenv on LC_COLLATE shows that emacs still thinks the value is 'C'; and ls -...