Questions tagged [sorting]
Use this tag when arranging items in order is the main focus of the code.
1,163 questions
4
votes
2
answers
118
views
Custom RowSorter that sorts a Swing table containing data with unit suffixes
I would like to hear what you say about my custom RowSorter implementation.
The following comparators should be used for the table columns: String, Double and Integer.
The table data has postfixes and ...
5
votes
6
answers
2k
views
Bubble sort with 10 random numbers
I want to make a bubble sorting algorithm of 10 random (non-repeating) numbers from 0-50. I changed many aspects of it while making it and finally got it to work, but I would like to see if there's ...
8
votes
5
answers
1k
views
LeetCode 977: Squares of a sorted array, maintaining non-decreasing order
I tried solving the LeetCode question like many others, trying to incorporate the O(n) time complexity requirement.
Squares of a Sorted Array
Given an integer array ...
5
votes
2
answers
203
views
Sorting file names of a RAR split archive (v3 and v5)
This simple task of sorting a list of related RAR files of a split archive turned out to be more cumbersome than expected, since there are two versions of the RAR naming scheme, v3 and v5.
v3 is like ...
7
votes
6
answers
1k
views
Fast allocation-free alphanumeric comparer used for sorting
I was searching for C# comparers that can be used for natural sorting ("a9" comes before "a11"), but most solutions have a lot of allocations, quite unreadable code or are not ...
2
votes
1
answer
85
views
Multithreaded Merge Sort Using ForkJoin Framework
I've implemented a multithreaded merge sort using Java's ForkJoin framework, and I wanted to gather feedback on its correctness, efficiency, and scalability.
Here's my implementation:
...
-4
votes
1
answer
105
views
Pyramidal (Heap) sorting by D. Knuth
Help me with Pyramidal sorting by D. Knuth algorithm in C++.
I would like to clarify if I followed the algorithm correctly.
The code works.
I have the function, but I'm not sure if my code fully ...
3
votes
0
answers
108
views
Comparing two Tree sort algorithm variations implemented in Java
I have this repository. It contains three variations of a simple sorting algorithm for integer keys.
The idea is that we keep a balanced BST in which each node holds the integer key and its frequency. ...
2
votes
1
answer
66
views
Advent of Code 2022 Day 13 Solution in C: Sorting and parsing nested list
Link to Original Problem: Advent of Code 2022 Day 13
Question Summary:
The task involves sorting and parsing nested lists, with two parts:
Determine pairs in the correct order and calculate the sum ...
3
votes
1
answer
123
views
Sorting the divisors of a given number
I am trying to sort all the divisors of a given number in the most efficient way.
Below is my code for sorting the divisors:
...
4
votes
1
answer
136
views
Efficient least-significant digit (LSD) radix sort for int keys in Java
(This post has a continuation post.)
This one is my attempt at LSD radix sort:
Code
com.github.coderodde.util.LSDRadixsort.java:
...
5
votes
1
answer
146
views
Sorting songs with the ability to save and resume partial sorts
I listen to a lot of music (~4k h/y) and managing thousands of songs is a bit of a challenging.
To improve my listening experience I want to better organize my collection.
One thing I want to do is ...
4
votes
1
answer
323
views
c++ quicksort pivots
Is this code for quicksort using the first index as a pivot correct?
Also if I want to use the last or middle index as a pivot how would the whole code change?
...
2
votes
1
answer
89
views
Sort array of numbers using tree sort - Leetcode 912
Problem statement:
Sort integer array nums in O(N log N) time,
without relying on any library sort routine.
I am trying to use a tree sort method (using the ...
1
vote
0
answers
33
views
Determine top t values with few calls to order(), a given procedure to order k values, Java take 2
My 2nd take of the problem in Determine top t values with few calls to order(), a given procedure to order k values:
Given an array and a procedure to order \$k\$ ...