77,938 questions
-8
votes
0
answers
75
views
How can I sort a dictionary by its values? [duplicate]
How can I sort a dictionary that has string as its key and an int as its value by its values?
I want to have a dictionary that counts how many times a word appears in a string, and I want to have the ...
1
vote
1
answer
59
views
Angular Material: Programmatically setting MatSort does not update UI sort arrow
I'm working with an Angular Material table (mat-table) that has sorting enabled via matSort. Sorting works perfectly when I click on the column headers (mat-sort-header).
Now, I want to trigger the ...
-3
votes
0
answers
78
views
Tournament Sort Correction [closed]
Im making a presentation as homework about it, there's barely any information of it, i been working with chatgpt and some youtube video, my question is, whenever i write same numbers, for example, ...
Advice
1
vote
8
replies
131
views
Making a palindrome out of a string of random letters (or any given value type inputs)
Found this code exercise on W3R. Been trying to figure out the relationship between the outer and inner loop (i and j), but can't seem to wrap my head around it. If anyone could walk me through this ...
3
votes
3
answers
199
views
How to sort a dictionary of word counts by value while preserving the original key order? [duplicate]
I am trying to count word frequencies in a text and then sort them in descending order of frequency. So if two words have the same frequency, they should remain in the same order they first appeared ...
-4
votes
0
answers
140
views
How do you make an algorithm that'll find the shortest way to sort a sequence of numbers by applying function that converts to closest lower prime? [closed]
Imagine you get sequence of integers:
[a1 a2 a3 ... an]
where:
1 <= a <= 10^6
1 <= n <= 10^6
You are given a function f(x) that can change a number to the closest lower prime number, or ...
Best practices
0
votes
0
replies
30
views
How to effectively implement sorting in universe basic programming language
The current version of universe programming language I working on does not cater for SORT function. For certain application , there a need read from a record file which contains over 100 items ...
0
votes
2
answers
75
views
(Shell Sorting) Applying Ciura's gap sequence (or some other optimal sequence formula)
I've been trying to teach myself various sort methods just for the sake of being able to use them in the future and right now I've been teaching myself about shell sorts. I understand the way shell ...
Tooling
0
votes
4
replies
109
views
Compare unordered lists / objects javascript
I would like to compare unordered lists / objects with an indeterminate depth in javascript like:
const t = {
key: [
{
subKey: [
{
subSubKeyOne: 1,
subSubKeyTwo:...
1
vote
0
answers
143
views
Quadratic behaviour examples generating of libc++ sort implementation
I'm studying sorting algorithms at the moment and I have one question that is actually quite well-known but still I can't find a full answer that is comprehensive enough for me. So, the topic is libc++...
Advice
0
votes
3
replies
100
views
Java : getting sorted order of Objects
I have an List of Objects that implements the Comparable Interface that I want to sort. I do not want the original List returned sorted, nor do I want an new List returned in sorted order. What I ...
Advice
0
votes
0
replies
39
views
How to show the H3 indexes order?
I would like to generate H3 grid with labels into its hexagons, following the index order and drawing its curve.
____
Note. This illustration is from another grid system, but I would like similar ...
0
votes
2
answers
174
views
Cannot get TList<>.Sort() to work in Delphi 11 FMX
I have been trying to sort a collection of objects. While I have seen many promising solutions, my compiler simply won’t accept them (error message in procedure GenReorderSpeciesList). I am using ...
0
votes
1
answer
69
views
How to filter data into another spreadsheet based on two values in the same column in google sheets
I'm making a book spreadsheet where I'd like formats to filter into a spreadsheet for physical books (Hardcover and paperback) and another for Digital books (ebooks and audiobooks). I can only seem ...
3
votes
3
answers
187
views
How do I cluster/group duplicate customer objects in my list based on email OR mobile in C#
For my current project in C#, I am tasked with fetching customer details from a data source, 'cleansing' said customers (making sure the name is capitalised correctly, mobile formatted correctly, etc.)...
1
vote
1
answer
46
views
Prisma - Sorting by function applied on a column
I want to use a function in my orderBy clause. To my great surprise I can't find a way in the official documentation to do this without executing raw SQL in Prisma. This is similar to what Python or ...
1
vote
2
answers
106
views
Typescript sort array of array tuples
I have tuples in the form (Status and priority)
[State,prio]
States are defined so:
enum State {
A = "A",
B = "B",
C = "C"
...
}
Now i want to sort an ...
3
votes
0
answers
129
views
Fast lazy sort & deduplication over multiple sorted lazy sequences in Clojure
I implemented a few lazy sort & merge functions that are used heavily in my ReBAC authorization library, EACL, to lazily "merge" & deduplicate ~1M datoms emitted from Datomic's d/...
2
votes
2
answers
142
views
Why is the worst-case binary selection sort time complexity considered O(n^2)?
Wikipedia and other textbooks reference binary selection sort's asymptotic worst-case time complexity to be O(n^2), usually justifying this with any extra computation caused by swaps. I don't ...
0
votes
1
answer
115
views
Sorting completed date in WooCommerce order list (admin dashboard)
I added a new column of completed date in the woocommerce order list page using the code here. The new column shows sorting buttons (up/down arrows) properly but when clicked, seems like it sorts on ...
0
votes
0
answers
51
views
Sorting items in a Pina store is very slow
I have a Pinia store defined like this:
export type Era = {
id: number
name: string
start_year: number
end_year: number
item_count: number
}
const settingStore = {
eras: ref([] as Era[])...
1
vote
1
answer
136
views
I need to sort a list of coordinate pairs by y decreasing then x increasing [duplicate]
I am trying to sort this list of pairs so they are ordered by y decreasing as the primary factor and x increasing as a tie breaker.
[['0', '0'], ['0', '1'], ['1','1'], ['2','1'], ['0', '2'], ['1','2'],...
0
votes
1
answer
70
views
Sort Tabs Alphabetically keeping Certain Tabs first and ignoring Hidden Tabs
I have a file that includes a variety of reference sheets and sheets that are only used at the end of the academic year plus a tab/sheet for individual students. Students come and go so I need the ...
1
vote
2
answers
147
views
How to sort only based on the value in the B column of every row?
This is what I am currently using for my code.
Private Sub CommandButton1_Click()
' Sort button and save a backup copy
Range("B1").Sort Key1:=Range("b3"), Order1:=xlAscending, Key2:...
-2
votes
1
answer
130
views
Is this a valid JavaScript approach for sorting large arrays of unique integers efficiently? [closed]
I’m experimenting with sorting large arrays of unique integers in JavaScript and came up with a simple approach. I’m curious if it’s a recognized pattern or if there are potential pitfalls I might be ...
0
votes
2
answers
98
views
Make onEdit work for two separate tables within the same sheet [closed]
How would I be able to make this function work for two separate tables within the same sheet?
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Leaderboard"); ...
2
votes
1
answer
95
views
Sort each row of a pandas column consisting of delimited strings
CONTEXT
Let's say I have df, which consists of a column of delimited strings that I would like to sort.
import pandas as pd
df = pd.DataFrame({'sort_me':['foo; bar','foo; bar','bar; foo']})
df
...
1
vote
2
answers
148
views
Room Database - Secondary ORDER BY not working Java
I have a RecyclerView list of CardViews for tasks, etc. Some of the CardViews have a due date attached to them, others have no due date. I want to show the CardViews with due dates on top of the ...
-2
votes
1
answer
129
views
Complex SQL query not sorting correctly
I have a complex SQL query that is not sorting the results properly. It is supposed to sort the list of questions in order of the ORDERS column of the Questions table, but instead, it is always ...
3
votes
0
answers
153
views
Encountering problems while making a sorting algorithm in python 3
I am an inexperienced coder, and took up the challenge to make a sorting algorithm to sort lists. I see people using the mod operator, and didn't like it, so I am using strings to make it a little ...
1
vote
2
answers
101
views
Sorting a list of objects. Is it possible to use a property as parameter?
This is a simple class (Person) with a shared list (Persons). My question concerns the possibility of improving the code in the method SortByPropertyName. It works as it is but, it would more handy if ...
-2
votes
1
answer
119
views
Array passed as an argument does not seem to be changing [closed]
I was tasked to write up a C program to sort an array using quicksort, without using recursion.
Original array:
-25, 87, 12, -6, 91, 3, -48, 70, 19, -33, 55, 2, -18, 99, 41, -72, 63, 15, -90, 27, 8, -...
-2
votes
1
answer
137
views
Python search in a sorted list if key is a part of a string using bisect
I have a list of pathnames (dirname+filename), sorted by filenames.
How to use bisect if I want to find a filename in this list ?
Example :
import os, bisect
lst=[]
for (dp, dn, fn) in os.walk(rep):
...
0
votes
1
answer
41
views
Sorting collection of objects which also have "parent/child" relations between them
Ive got this conceptual problem I've been looking at. Have a collection of objects I need to sort by one or the other field but theres should in ordering also be taken account that objects are chained ...
7
votes
3
answers
441
views
How to sort pandas groups by (multiple/all) values of the groups?
I am trying to do a somewhat complicated group and sort operation in pandas. I want to sort the groups by their values in ascending order, using successive values for tiebreaks as needed.
I have read ...
0
votes
2
answers
73
views
Dynamic column sorting in angular primeNg
I am rendering the table using angular primeNg based on a condition. All the headers and values are coming dynamically. The table data is getting displayed properly. However the sorting is not working....
1
vote
1
answer
133
views
Forcats & Dplyr_ How to order the columns-specific levels of factors by alphabetical order in a fast and tidy way?
I'm a beginner at R and tidyverse. I'm looking for a fast solution using
mutate(across(c(col1, col2, ...),
~ create factors with levels sorted by alphabetical order)))
the base function factor() ...
4
votes
2
answers
155
views
Why does the sort method used by Postgres change from "top-N" to "external merge" when FOR UPDATE is added?
I have a table in Postgres (14) that is used like a queue with FOR UPDATE SKIP LOCKED queries. It was missing an index, but since any rows are usually processed quickly that never became a problem. ...
0
votes
0
answers
41
views
Sorting in Custom MUI Table with Formik Editable Fields is very slow
I have an InvoiceTable component and a custom editable invoice field.
I am using Formik, and I am calculating an initialSortedData before Formik is initialized.
Once Formik is initialized, all data, ...
0
votes
0
answers
30
views
Query for different representations of document with correct sorting
I have an index of documents that consist of some data that may exist differently in the so-called draft or release versions of the document. In my example mapping, I have only the docType as a value ...
3
votes
0
answers
173
views
How to reorder a sorted Dutch flag array to wiggle order in O(1) space
Given an array already sorted in Dutch flag, i.e., it meets following requirements:
Each element within nums[:i] is smaller than mid.
Each element within nums[i:j] equals mid.
Each element in nums[j:]...
1
vote
1
answer
34
views
Using sort with numeric columns separated by letters & underscores
I'm trying to sort phrases such as the following:
a12_b7
a12_b11
a5_b3
a5_b30
a12_b10
using the numbers following the letters, lexicographically. For the example above, I expect the result to be:
...
-1
votes
1
answer
63
views
Sorting text lines by a field formatted as time stamp with shell commands [closed]
I want to sort lines with time format strings using shell command.
Shell shall be a common linux shell.
Example input:
results/fn_a:# Generated on: Mon Jul 21 17:20:48 2025
results/fn_b:# ...
0
votes
2
answers
128
views
How to sort a dictionary with list of datetime objects as value?
I have a dictionary with lists of datetime as value:
month_a = [8,9,10]
day_a = [13,12,15]
month_b = [8,9,10]
day_b = [13,11,13]
dt_a=[]
for m,d in zip(month_a, day_a):
dt_a.append(datetime....
1
vote
1
answer
120
views
how to restore the selectedrows after sorting in dbgrid and clientdataset
My DBGrid is connected to a Datasource / ClientDataset / Provider / ADOQuery
I sort the grid with this code, which seems to work well
procedure TDataModuleBase.SortClientDataSet(AscendingFields, ...
1
vote
3
answers
80
views
Problem trying to sort images alphabetically by file name that have been loaded into a div via file reader
I am trying to load images into an html document using the file reader API, and then sorting them alphabetically. The code I have written loads the images into the div just fine, however it doesn't ...
1
vote
2
answers
102
views
Rust borrow checker: "cannot borrow `...` as immutable because it is also borrowed as mutable [E0502] immutable borrow occurs here"
I wanted to implement the Merge Sort algorithm, but I am having trouble with the borrow checker rules.
The compiler gives me the hint:
cannot borrow *lst as immutable because it is also borrowed as ...
0
votes
0
answers
42
views
How to always keep specific values (e.g. "untouched") at the bottom when sorting a column in MUI DataGrid?
I'm using MUI X's DataGrid in a React project and I want to sort a time column that contains either a date string (e.g., "24 September 2024, 10:48 am") or the literal string "untouched&...
0
votes
1
answer
78
views
How to handle sorting, filtering and pagination in the same ListView
GitHub link: https://github.com/IgorArnaut/Django-ListView-Pagination-Search-Sorting-Issue
I have an issue with the ListView.
I have pagination, side form for filtering and a form with select for ...
0
votes
0
answers
59
views
Why is the sorting result of Python lists so strange when the key function uses .count()? [duplicate]
The code is as follows, using key function to count the number of times each element appears in the list:
input_list = list('aaddccdc')
input_list.sort(key=lambda i: (-input_list.count(i), ord(i))) ...