Questions tagged [sorting]

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

61 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
138 views

Engineering an even faster qsort

I understand that C++ STL template sort runs faster than qsort in C because ...
7
votes
1answer
267 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 ...
7
votes
0answers
98 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
167 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
0answers
79 views

Rust Iterative and Recursive Merge Sort Implementation

I'm in the process of learning both Rust and algorithms after primarily focusing on web development. As such I've had a go at implementing merge sort both iteratively and recursively. I've looked for ...
4
votes
0answers
53 views

Opinion on a small app I created using JavaScript

Recently I created a small app using JavaScript, and I would love for some JavaScript developers if they have the time of day, to tell me their opinions so I can grow and improve. I'm mostly working ...
4
votes
0answers
739 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
202 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
299 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
65 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
83 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
89 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
126 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
512 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
1k 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
0answers
65 views

Python's quicksort algorithm

I was playing around with sorting methods, brushing up on my algorithms. I have made the following implementation of quicksort: ...
2
votes
0answers
56 views

Construction of external sorts from comparison ones

Here's an example how to construct an external sorting algorithm from the Quicksort. The method may be applicable to other known internal comparison sort algorithms. I have checked that it shows N*...
2
votes
0answers
63 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
85 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
43 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
244 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
344 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
69 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
4k 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
1answer
85 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 ...
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
213 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
151 views

Insertion sort slower than bubble sort

...
2
votes
0answers
269 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
115 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
110 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
42 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
379 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
57 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
208 views
1
vote
0answers
34 views

Sorting Algorithm Visualiser in Javascript

I'm new to Javascript and Web Dev in general, so they'll likely be some conventions that I'm not aware of. I'm at an odds of whether to use Javascript's functional features more. In my opinion it's ...
1
vote
0answers
74 views

Python Bubble sort

...
1
vote
0answers
48 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
272 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
49 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 quicksort. (20 ...
1
vote
0answers
731 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
0answers
341 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
0answers
565 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
55 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
397 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" ...
1
vote
0answers
592 views

Sorting directed graph topological using Kahn's algorithm

For a course I'm doing I need to get up to speed with Java, but unfortunately only Java 1.6 - here is a topological sorting algorithm in said Java version, for practice reasons: ...
1
vote
0answers
125 views

Selection and Insertion sort in Rust

I have been learning programming for better half of a year now and recently started learning Rust. This is my attempt at implementing selection sort and insertion sort. Since I tried to implement both ...
1
vote
0answers
545 views

Compute the minimum distance between two points in a 2-D plane

I have tried to calculate the minimum distance between the two points in a 2D plane. I have used the divide and conquer strategy to attain the complexity of n logn. ...