Questions tagged [sorting]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
44 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
78 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 ...
1
vote
0answers
23 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?
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
102 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
42 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
60 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
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 ...
3
votes
1answer
54 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
2answers
42 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
120 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
54 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
33 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 ...
0
votes
1answer
38 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
1answer
42 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 ...
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; ...
2
votes
2answers
259 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 ...
4
votes
2answers
102 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
207 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
200 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
320 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
45 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
61 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 -...
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 '(...
1
vote
1answer
207 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
129 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 ...
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
115 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
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
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 ...
1
vote
1answer
640 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
362 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
179 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
99 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
118 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
178 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
670 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
62 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
166 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
116 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
98 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 ...
4
votes
1answer
118 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
118 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 ...
2
votes
0answers
65 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 ...
9
votes
1answer
189 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 ...
3
votes
1answer
110 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 ...
4
votes
2answers
177 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,...
1
vote
2answers
204 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 '...
2
votes
2answers
132 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 ...