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
2
votes
1answer
48 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 ...
5
votes
2answers
314 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 ...
1
vote
1answer
47 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 ...
2
votes
1answer
79 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 ...
7
votes
2answers
221 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 ...
1
vote
0answers
26 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?
23
votes
4answers
5k 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 ...
1
vote
1answer
21 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 ...
7
votes
1answer
107 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 ...
2
votes
1answer
43 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, ...
1
vote
1answer
43 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
62 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-...
3
votes
1answer
58 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 ...
0
votes
1answer
39 views

How to NOT sort icicles menu output?

Using an icicles menu with emacs 26.1, I'm now having the menu sorted. The menu used to be unsorted (items appeared in the order they were given). In the previous version of emacs they were unsorted. ...
0
votes
2answers
43 views

How to sort lines ignoring a pattern?

I would like to sort some lines, ignoring a leading part of them. Here's an example from my .spacemacs file: '( better-defaults elixir emacs-lisp erlang evil-commentary ...
2
votes
1answer
127 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-...
0
votes
1answer
64 views

How to convert paragraph into the line?

I've need a function which convert a paragraph into the line, sort each space separated set of characters and fill it back to paragraph. In: Supposedly there are over one million words in the ...
1
vote
1answer
58 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 ...
0
votes
1answer
35 views

Sort js object by name

I'd like to sort objects by prop name, eg const a = { method: "GET", url: "asd", headers: { Content: "application/json", Authorization: "token", }, } then select only ...
1
vote
0answers
45 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; ...
0
votes
1answer
44 views

How to sort a list of files/directories by hierarchical depth?

I am working on implementing my own feature request -- http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31601 -- to give wdired the ability to handle a dired- buffer that contains an arbitrary list of ...
6
votes
2answers
339 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:...
1
vote
1answer
137 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 ...
2
votes
2answers
271 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
3answers
117 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 '(...
4
votes
2answers
105 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 ...
0
votes
1answer
216 views

Open emacs in Dired mode

I would like to open emacs in dired mode . files and folders should be organised in most recent file first order. Moreover I would like to highlight the Org files for easy selection. Is this possible?
5
votes
2answers
209 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?
2
votes
1answer
340 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 ...
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
62 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 -...
1
vote
1answer
217 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 ...
0
votes
1answer
47 views

Custom sort order based on certain elements of a list

Q:  Each sub-list within the main list contains one of five possible categories. How can I customize the sort in the following order: CUSTOM SORT ORDER: 1. TASKS 2. EVENTS 3. UNDATED 4. ...
0
votes
1answer
69 views

Custom function to map through nested lists sorting by time-stamp

In the following example, please assume that we are using time-to-seconds to convert each times-stamp into a decimal representation. I have already converted the time-stamps to seconds in this ...
0
votes
1answer
120 views

org mode sort problems with (numerical) properties

I use the property "pages" for the number of pages of an article or book. There are two problems. First: If I use C-c ^ to sort the items by the value of pages org-sort seems to interpret the ...
0
votes
1answer
42 views

Idiomatic boolean comparators

Are there idiomatic boolean comparators in emacs lisp? Something like: (my/bool< nil t) => t (my/bool< 1 2) => nil For example, a comparator that returns t if the first argument is ...
2
votes
2answers
183 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) ...
1
vote
1answer
669 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:...
2
votes
1answer
374 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-...
1
vote
1answer
103 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
0answers
120 views

order agenda so all-day and multi-day duration items appear on top

My problem is with two of my main use-cases for time-stamped items (essentially events). Consider these two org-mode items: * Clojure Dojo at uSwitch <2016-11-14 Mon 19:00> * Trip to Jamaica &...
1
vote
1answer
184 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?
6
votes
1answer
707 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 ...
1
vote
1answer
63 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 ...
0
votes
0answers
170 views

Org-mode: manually sorting headlines column view

I love that we can quickly re-order our outlines with the M-<Up|Down> arrow keys. For whatever reason, I can't get this to work in column view. I would like to enable this behavior. Any ideas ...
1
vote
1answer
119 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 ...
3
votes
2answers
99 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 ...
9
votes
1answer
191 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 ...
4
votes
1answer
119 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 * ...
5
votes
1answer
121 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 ...