As of May 31, 2023, we have updated our Code of Conduct.

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
3 votes
2 answers
206 views

How to ignore accents (À Â É Ê etc.) when sorting?

When sorting text with Emacs, the result is wrong for accented characters: Always Emerald Yesterday Zoo À la campagne Âge Écarlate Être Here is the result I would like instead: À la campagne Âge ...
Carapuce's user avatar
3 votes
2 answers
166 views

How to sort structured blocks?

There are cases where I wish to sort data that has been wrapped across multiple lines, making a simple line-sort not work usefully e.g. '("x" "b" "c" "a lot of text&...
ideasman42's user avatar
  • 8,209
4 votes
1 answer
45 views

Display completion options from top to bottom in alphabetical order?

Completion are currently listed in alphabetical order as a b c d e f With alphabetical order going from left to right. How can I can change this to. a c e b d f With alphabetical order going from ...
Progamer's user avatar
1 vote
2 answers
91 views

Sort text by group in markdown

I'm not a tech person. I've been using Neovim for the last year or so for writing, and I love it. But I'm considering making the switch to Emacs for the ability to use non-mono fonts. I use markdown ...
Euth38348's user avatar
0 votes
1 answer
63 views

Sort org-agenda entries chronologically with grid in the middle

Is it possible to get my items sorted in a chronological manner, such that the grid remains in "today" relative to other entries? Something like this: cat1: sched 5 days ago TODO task 1. ...
onlycparra's user avatar
1 vote
2 answers
122 views

Incorporate a list of floats, into another list of floats, in numerical order, with remainders

In this example, there is a list of miscellaneous orphan floats '(9.9 10.1 10.3 10.5 10.7 10.9 11.1) that needs to be incorporated in numerical order into a second main / master list (10.0 10.2 10.4 ...
lawlist's user avatar
  • 18.6k
1 vote
1 answer
48 views

Sorting counts in descending order

Have the following code that counts the number of times words are used. I want to list the results sorted by the number of counts. (defun rk-word-analysis (reg-beg reg-end) "Count ...
Veak's user avatar
  • 199
0 votes
1 answer
38 views

sort: How to specify the order in which multiple sorts are performed

In the following example, there are two criteria for sorting -- orders with an inactive status should appear last in the last, and all orders should be organized by order number from smallest to ...
lawlist's user avatar
  • 18.6k
-1 votes
2 answers
40 views

Not correct reverse sort in dired mode

Linux Mint 20.2 Emacs 27.2 Installed packages: dired+ dired-hacks-utils-20201005.2318 dired-k-20200322.2035 dired-narrow-20181114.1723 dired-quick-sort-20201221.403 dired-recent-20211004.1924 dired-...
a_subscriber's user avatar
  • 3,830
0 votes
1 answer
47 views

How can I sort a list of buffers according to a buffer-local variable?

I am setting a buffer-local variable called my/tab-order in (some) of my buffers. I have written the following function to return a list of buffers only where my/tab-order has been set and is greater ...
randouser's user avatar
0 votes
2 answers
105 views

Sorting lines based on numbers in unicode

I want to sort some text in emacs that is based on a field that contains verse numbers in unicode (devanagari). The text is like this: Verse text bla १०.३ #10.3 Verse text blah This is १.१९ #1.19 ...
linuxfan's user avatar
  • 189
1 vote
1 answer
54 views

Get company to sort single underscore before double underscore, specifically with elpy/python-mode

Edit: this question is a duplicate of this one; I'm leaving it because I got a helpful answer and I didn't find the other one after reasonable amount of searching (so I hope this one being here will ...
Levin Magruder's user avatar
0 votes
1 answer
53 views

How to activate functions on .org files from within agenda view?

From agenda view, is it possible to execute functions on specific .org files? Example setup: foo.org and bar.org are source files for agenda Example working function from : Sort entire hierarchy in an ...
XLIII's user avatar
  • 13
2 votes
1 answer
129 views

C-x C-f TAB TAB: Find file completion list: how to highlight subdirectories?

Often I'd like to open a file in a subdirectory. But poor me, I can't remember the name. So when typing C-x C-f and then TAB TAB for the completion list, the list of all files in this directory is ...
Keks Dose's user avatar
  • 498
1 vote
1 answer
95 views

The list-buffers command. How to make the 'Buffer' column sort case-insensitively, when click on it?

C-x C-b is normally bound to the list-buffers command. The resulting buffer has various columns, which are CRM, Buffer, Size, Mode, and File. When I can click on the Buffer column-header, it will ...
Rolly's user avatar
  • 11
2 votes
2 answers
33 views

Sort lines omitting a prefix of a certain length?

Many of my python files have an import section that looks like this: from datetime import datetime, timedelta from typing import Callable import numpy as np import pandas as pd I'd like to sort ...
Jeffrey Benjamin Brown's user avatar
1 vote
2 answers
129 views

How to add a string at nth position of an ordered list of strings

The built-in function add-to-ordered-list is for symbols, not strings. I have a list of strings and need to add another string to the list at a specific nth position. How can I accomplish this? TASK:...
lawlist's user avatar
  • 18.6k
0 votes
1 answer
253 views

How can I sort Org headings by value in :properties:

My org file structure is this: * Heading 1 :PROPERTIES: :EVENT_CREATED: [2016-11-28] :END: * Heading 2 :PROPERTIES: :EVENT_CREATED: [2016-10-27] :END: * Heading 3 :PROPERTIES: :EVENT_CREATED: [2019-02-...
Harry's user avatar
  • 1
0 votes
0 answers
88 views

Sorting todos by custom todo label when invoking `org-todo-list` with `C-c a t`

I have defined some custom todos keywords with (setq org-todo-keywords '((sequence "TODO" "TODAY" "IN-PROGRESS" "WAITING" "URGENT" "FUTURE&...
Nisba's user avatar
  • 855
0 votes
0 answers
59 views

Emacs on Windows. Dired - no sorting. Unrecognized symbols

Set up Doom Emacs on windows. Works fine but in Dired i have unrecognized symbols and also in org-capture. Sorting in dired does not work either. Any ideas? Latest Emacs.
Roman Smirnov's user avatar
2 votes
1 answer
91 views

Custom agenda sorting by CREATED date

I put together the function below but it doesn't work. The problem is get-text-property returns nil for every task. Any idea how to get the CREATED property and fix the entire thing? (defun jarfar/org-...
Navidot's user avatar
  • 692
0 votes
1 answer
140 views

How to efficiently merge 2 buffers which are partially overlapping?

Problem summary Imagine, you have 2 shopping lists: 1 huge one with hundreds of entries - list A, copied into buffer A 1 containing dozens of entries - list B, copied into buffer B Then: 75% of ...
starquake's user avatar
3 votes
1 answer
185 views

Sort Chinese Characters in Emacs

Is there a ready-made function that sorts Chinese characters (by pinyin or stroke number) in Emacs in an org-table or line by line in regular text? If not, how should one go about writing such ...
Sati's user avatar
  • 755
1 vote
1 answer
698 views

How to sort in Dired by size and extension and have directories listed first and full date/time details

I'm using the excelent dired-fixups.el by Dino Chiesa for sorting in Dired by size and extension (see here). The only gotcha is that I'd like to combine it with a fuller date/time description. Also, ...
Daniel's user avatar
  • 89
2 votes
1 answer
221 views

Is there a way to change order of the key in a hashtable?

Say i have following keys in hashtable: "first1" "second2" "third3" "forth4" Is there a way to put key "third3" at the top. So that when i run func hash-table-keys i get following list: ("third3" "...
Sime1's user avatar
  • 31
5 votes
0 answers
240 views

Sort ripgrep results based on proximity to current buffer

I use counsel-projectile-rg to search within the project I work on. But there is my sub-project inside this big repo that most of my development is in. Is there a way to sort ripgrep results based on ...
SFbay007's user avatar
  • 554
2 votes
1 answer
321 views

How to sort comma separated (or otherwise) text?

Suppose I have the following text: int z; int a; int c; int g; or the following text: z, a, c, g How can I sort them to: int a; int c; int g; int z; and a, c, g, z respectively?
Prikshet Sharma's user avatar
6 votes
1 answer
1k views

Ivy: sort candidates by most recently used

I'm coming from Helm to Ivy just to try it out, and one thing I miss greatly from Helm is how the default candidate when hitting M-x is whatever the last command was. Is there some way to sort Ivy's ...
Ashton Wiersdorf's user avatar
1 vote
2 answers
160 views

How to order a single line relative to other lines in a block of text?

How can a line be sorted relative to other lines at the same indentation level? This would be useful whenever adding an item to an ordered list of definitions (file lists or forward definitions). ...
ideasman42's user avatar
  • 8,209
1 vote
0 answers
61 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 ...
Edman's user avatar
  • 1,143
1 vote
1 answer
41 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 ...
a_subscriber's user avatar
  • 3,830
0 votes
0 answers
321 views

how to sort tasks in agenda using todo-state-up?

I defined 4 TODO keywords. Two are in the TODO state and two others (DONE and CNCL) belong to the DONE state: (setq org-todo-keywords '((sequence "TODO" "WAIT" "|" "DONE" "CNCL" ))) I defined ...
midas0441's user avatar
  • 304
0 votes
1 answer
59 views

emacs ruby mode: can I reorder methods in file (alphabetical order)

After opening the file app/controllers/pages_controller.rb Which has class PagesController < ApplicationController def foo puts "foo" end def baa puts "baa" end end I ...
american-ninja-warrior's user avatar
3 votes
1 answer
149 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 ...
rich ratzan's user avatar
1 vote
1 answer
478 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 ...
Alex's user avatar
  • 781
2 votes
1 answer
128 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 ...
Felipe's user avatar
  • 241
2 votes
1 answer
128 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?
Toothrot's user avatar
  • 3,114
1 vote
1 answer
145 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 ...
user1735594's user avatar
7 votes
1 answer
324 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 ...
Dan's user avatar
  • 32.3k
2 votes
1 answer
132 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, ...
Croad Langshan's user avatar
1 vote
1 answer
411 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-...
John Kitchin's user avatar
  • 11.5k
1 vote
1 answer
112 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 ...
scaramouche's user avatar
  • 1,760
3 votes
1 answer
418 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 ...
Ivan Perez's user avatar
3 votes
2 answers
140 views

org-mode error: Region to sort contains a level above the first entry

When calling org-sort-entries on an outline item, I get the error Region to sort contains a level above the first entry with no indication of what or where the problem is. What does this error mean, ...
Brian Burns's user avatar
  • 1,547
0 votes
2 answers
156 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 ...
mkaito's user avatar
  • 731
2 votes
1 answer
286 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-...
Lore's user avatar
  • 164
0 votes
1 answer
153 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 ...
Hellseher's user avatar
  • 123
2 votes
1 answer
259 views

Sort entire hierarchy 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 *** 2 *** 3 ** C *** 1 **...
deshmukh's user avatar
  • 1,842
0 votes
1 answer
130 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 ...
Daniel Pérez's user avatar
0 votes
1 answer
53 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. ...
ideasman42's user avatar
  • 8,209