We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [sorting]

Sorting is the process of applying some order to a collection of items.

67 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
98 views

Engineering an even faster qsort

I understand that C++ STL template sort runs faster than qsort in C because ...
7
votes
0answers
93 views

Stable variation of built-in sort

Ruby's built-in sorts are unstable. The stable_sort gem monkey-patches Ruby's built-in library to have stable sorts which include nearly all the functionality of the built-in sorts, but with the ...
6
votes
0answers
188 views

Object-Oriented Sorting Algorithms

I would like a review of a library I've recently published. I realize this is a rather large request, but having looked on meta, it seems this is perfectly on-topic. I'll include a few choice samples ...
5
votes
1answer
75 views

Sorting software version list using Python 2.7 (no modules)

I am participating in a challenge and one of the challenges was to write a script to sort a list of software versions (ex: 1.0, 1.3.2, 12, 1.3.0). Here is the my solution: ...
5
votes
0answers
143 views

Selection sort with reduced comparison count: Python iteration 2

Follow up to Selection sort with reduced comparison count - semi-final Iteration? My goal (and excuse not to tag reinventing…) is to have presentable code to argue the viability of reducing the number ...
4
votes
1answer
233 views

Bubble sort algorithms and unittest in Python

I am quite new in Python and I am starting my journey with sorting algorithms, PEP8 and the Zen of Python. So far i wrote a post BubbleSort and I drew conclusions and followed the advices. I ...
4
votes
0answers
527 views

Selection sort implementation in C++ iterator approach

I am trying to learn the C++ way of writing code. I was wondering if this code could be improved or if there are any major mistakes. Is it ok how I name the variables? ...
4
votes
0answers
188 views

Heap sort in Rust

The tests are taken from this answer on an insertion sort in rust question. The algorithm is taken from Algorithms in a Nutshell (2nd Edition). I'm not looking at crazy performance, the goal being ...
4
votes
0answers
2k views

Integer tree sort in Java

I have this algorithm for sorting integer arrays. Basically, it's a balanced tree sort which creates a tree node for each distinct integer, and in each tree node it maintains a counter counting how ...
4
votes
0answers
297 views

Quick Insert Merge Sort

I have written this code to sort a list of numbers, in increasing order. It is a combination of quick sort, insertion sort, and merge sort. I make the first element of the list a pivot, then I go ...
3
votes
0answers
46 views

DataManager Class: Sorts Array by 1 or More Dynamically Added Columns in Ascending or Descending Order

I've been struggling to write a QuickSort algorithm to sort multiple columns of an Array for weeks. Finally, I decided to write a class that Implements mscorlib.IComparer and it has exceeded my ...
3
votes
0answers
72 views

Sorted LinkedList

A linked list is a data structure that has a beginning, and an end. The only way through the structure is to go to the "next step", like stepping stones. This linked list works the same way, but in ...
3
votes
0answers
84 views

Comb Sort Multi-dimensional Array on Key

Previously: Comb Sort in VBA I've been running two different comb sorts (on arrays) depending on whether I want to sort numbers or strings and I figured I would give using ...
3
votes
0answers
118 views

Shakesort in Python 3

I've done the shakesort algorithm win \$O(N^2)\$ but it doesn't seem that \$O(N^2)\$ is correct because it takes 6-9 steps in the while loop for a list of 4 ...
3
votes
0answers
68 views

Adaptive counting sort for integer arrays in Java - follow-up

I have refactored this. Once again, the running time can be anything between \$\Omega(n)\$ and \$\mathcal{O}(n^2)\$, yet it adapts to "smoothness" of the input array. ...
3
votes
0answers
454 views

Parallel Merge Sort in Scala

I have been trying to implement parallel merge sort in Scala. My current implementation is about as fast as .sorted, but I have no idea what would be the right ...
3
votes
0answers
999 views

Nuts and bolts algorithm

I am trying to learn Golang. This is a problem from Robert Sedgewick's Algorithms book: You have a mixed pile of N nuts and N bolts and need to quickly find the corresponding pairs of nuts ...
2
votes
1answer
35 views

Naive implementation of sort inplace

I had the following assignment for the Python 101 course I'm taking in my university. ...
2
votes
0answers
59 views

Vanilla Javascript code to sort nested tables

I have written a code to sort a main table containing tables in each of its rows. Here I am trying to sort the table by first sorting the rows in each of the main rows and then sorting the table from ...
2
votes
0answers
63 views

Efficient counting sort for large byte arrays in Java

I have this counting sort for byte values running in linear time with respect to array length: Arrays.java ...
2
votes
0answers
77 views

Generate automatically new groups in a tournament

I'm trying to model a tournament with Python (Django) and I've got a function that assigns teams of the previous stage to the groups of the new one. The teams in the first stage are assigned manually....
2
votes
0answers
38 views

Sort ascending/descending functionally

I've been trying to get into functional programming with javascript and have tried to make some experiments with currying and function composition. What I've played with so far is a sorter function ...
2
votes
1answer
143 views

Sorting function from a React app to display JSON data in a sortable table

I created this simple react application for a coding challenge, which is described in the linked README file. Basically, I created the components and helper logic to display dynamic JSON data in a ...
2
votes
0answers
276 views

React widget to display, sort and search remote data

I've created a React widget that pulls data on crypto-token pairs from a remote API and makes that data sortable by headers and searchable. You can view a demo of it here. Is this a maintainable way ...
2
votes
0answers
58 views

Mergesort in Python optimization

I am currently writing mergesort in Python and have implemented it to work. I have noticed, though, that it is very slow compared to the standard sorted() method. I understand it will always be faster ...
2
votes
0answers
3k views

Bubble sort using user inputted numbers and size in MIPS assembly

I made this code to take user input, making a specific-sized array and printing user-inputted numbers after being sorted. It works well but I was wondering if there was a way to "shrink" it down. It ...
2
votes
0answers
1k views

Visualization of sorting algorithms

I recently started to learn Qt framework and decided to create an app to visualize the sorting algorithms(for this moment there are 5 sorting algorithms). I just want to know if I'm doing everything ...
2
votes
0answers
198 views

Comparing speed of common sorting algorithms in an extensible way

I have written a program with the goal of comparing the speed of some common sorting algorithms. It works with many data types. ...
2
votes
0answers
147 views

Insertion sort slower than bubble sort

...
2
votes
0answers
245 views

Follow-up 1: Compare 2 unordered, rooted trees for shape-isomorphism

The previous post can be found here. In the previous post I tried to solve an exercise but found through the answer of Peilonrayz a bug in the code and 2 more while fixing it. These have now been ...
2
votes
0answers
114 views

Sorting overlapping shells in dynamical simulation - for loops vs array methods

I didn't know whether it was best to start with the general task I'm trying to solve, or the meat of the programming problem. They're both below but the former is rather long and solving the latter ...
2
votes
0answers
108 views

Z sorting implementation for a 2D isometric game

This is a naive implementation of a Z-sorting in order to fake 3D depth using sprites in a 2D scene. I would appreciate feedback on this, especially for performance as this has to be called each frame ...
2
votes
0answers
41 views

Sorting upcoming events listed in JSON

I've written my first program in GO, a command line tool that parses JSON containing events from a file or from STDIN and outputs the upcoming events in sorted order. Please critique it! ...
2
votes
0answers
360 views

Shell Sort code

I have a working shell sort code. I had already written a code for insertion sort, which I have used as underlying algorithm for doing shell sort on sub lists. So if you pass value of ...
2
votes
0answers
42 views

Guidance on grouping equal sets of numbers, so each group has a similar average

Goal: I am trying to build teams of 5 people. Each person has an integer elo (rank). My goal is to make all the teams as equal/fair as possible, by having the average elo of each team be as close as ...
2
votes
0answers
205 views
1
vote
0answers
65 views

Python Bubble sort

...
1
vote
0answers
31 views

Sort an array of strings using bubble sort

I have this following code to sort an array of strings order by ASCII value (alphabetically) using bubble sort. ...
1
vote
0answers
76 views

Median of three partitioning taking more time than standard quicksort in java

I implemented a standard quicksort and I have a project where I need to improve it. I am trying to make quicksort faster by implementing median of 3 partitioning. I copied codes from trusted ...
1
vote
0answers
134 views

Median of 3 partitioning taking more time than quicksort in java

I have a quicksort code in java which I want to improve. The improved code should take less time than the quicksort code. However when using my improved code which implement median of 3 partitioning, ...
1
vote
0answers
48 views

Sorts (merge, quick, bubble) in Python

I'm new to python, and I wrote the following code. Please review, critique and enhance. This project compares quicksort, mergesort and bubblesort write/test the partition routine for ...
1
vote
0answers
45 views

Sorting an array of numbers in Java with an algorithm

This is pretty much one of my first programs that I have created in Java and I just wanted to ask if anyone sees some obvious errors or mistakes I made. The purpose of this program is to sort numbers ...
1
vote
1answer
270 views

Bubble sort in Python

I am quite new in Python and I am starting my journey with sorting algorithms, PEP8 and the Zen of Python. I would like to get some feedback about my BubbleSort algorithm which I wrote. Also, is there ...
1
vote
0answers
436 views

Sorting cards by suit and value using Shell Sort

The question description: put a deck of cards in order by suit (in the order spades, heart, clubs, diamonds) and by rank within each suit, with the restriction that the card must be laid out face down ...
1
vote
1answer
56 views

Quicksort implementation with pivotal calculated as middle element

I read quick sort algorhitm and implemented in like this: ...
1
vote
0answers
268 views

Merge two unsorted array of numbers into sorted array using divide and conquer

I have done an implementation of merging two unsorted array of numbers into single sorted array. I have used the concept of divide an conquer. The code is as follows ...
1
vote
1answer
70 views

Searching and sorting ranges in excel with toggle buttons

I have a spreadsheet containing ±100 named ranges (5 rows, 15 colums) which are sorted based on time. My plan was to make toggle buttons to hide or unhide named ranges when they contain a certain ...
1
vote
0answers
384 views

Applies the Largest Remainder Method to a number property in a list of objects

I need to round BigDecimal numbers according to the Largest Remainder Method (LRM). Please reference this SO post with this answer. Here's my version of the algorithm in Java: ...
1
vote
0answers
54 views

Sorting BIGINT column with ascending positive values followed by descending nonpositive values

I have a column flowing in with the full range of integers. Whilst generating keys on the INT column, I need to push the 0's and negatives down (ordered DESC) and ...
1
vote
0answers
389 views

Last element pivot Quicksort exercise in TypeScript

Never being good in "algorithming", I'm now trying to improve the situation a bit. An algorithm below is the attempt to home brew yet another quicksort. This time, specifically with a "last-element" ...