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

learn more… | top users | synonyms (1)

0
votes
1answer
34 views

Alphabetical Sort

I have the following first-letter only alphabetical sorting algorithm: Note: FileManager is just a file I/O class that reads in the unsorted words from a textfile ...
3
votes
2answers
47 views
3
votes
3answers
80 views

Natural merge sort in C

I have this C implementation of the natural merge sort: ...
-3
votes
0answers
44 views

What is wrong with my quicksort algorithm? [on hold]

I tried writing quicksort algorithm recursively and using lomuto partitioning scheme. But there seems to be something gravely wrong with it. It works only for small inputs but takes forever for even ...
-1
votes
0answers
37 views

Selection sort algorithm for a 2d char array in C [on hold]

I am trying to make a selection sort algorithm for a 2d array in C (as the title says), the code compiles but unfortunately it does not sort anything. is there anything I can change that will make ...
0
votes
2answers
48 views

Custom sorting function implemented as a jQuery plugin

I was asked to create a jQuery plugin that would sort homogeneous DOM elements in a given DOM container element. I came up with the idea to attach data-priority ...
4
votes
2answers
46 views

Vector Sort Function

I had heard about sorting for a while, but never actually gave it a try. So I decided to make an algorithm that would sort the members of a vector from least to greatest. Though this may seem pretty ...
1
vote
2answers
42 views

Sorting an object array

I've created a class called Box that is pretty much what it sounds like. I want to sort these box objects, and I have created a function to do so. ...
-1
votes
0answers
22 views

Sort strings using selection sort without changing original values [closed]

I've created a function that sorts strings using selection sort, but I want to know if I can do this without changing the original strings. For example, if I try to sort an array ...
1
vote
1answer
91 views

Random maths quiz with sorting

...
5
votes
3answers
128 views

Heapsort in Python

Please review the following in-place implementation of Heapsort in Python: ...
3
votes
2answers
88 views

Slow merge sort

...
3
votes
4answers
102 views

C++ Interrupted Bubble Sort

I've written an interrupted bubble sort, which prints the intermediate result after some specified number of iterations of bubble sort. But I seem to have an speed issue. Could anyone help me spot ...
8
votes
3answers
452 views

Integer quicksort in Java

I have this Quicksort implementation that sorts arrays of int (not Integer). It has comparable performance to Java's ...
1
vote
2answers
51 views

Implementation of merge sort in Python

I was working on an assignment and I was hoping to know if the merge sort algorithm I wrote in Python was not making any unnecessary computations. ...
5
votes
2answers
176 views

Custom sorting of dates

I have implemented a class which implements a list of my custom DateObj. I have sorted the list in a peculiar manner based on the current month. I achieved my ...
7
votes
5answers
121 views

A few sorting algorithms implemented in C

I was reading about the elementary sorting algorithms like insertion Sort, selection sort and bubble Sort in Introduction to Algorithms by Cormen and I decided to try and implement it in C. ...
6
votes
3answers
70 views

Selection sort algorithm with increasing/decreasing sort options

I am running through some traditional algorithms in Go, and I was hoping to get feedback on efficiency and optimization. Below is a basic selection sort algorithm that takes a parameter to dictate ...
5
votes
2answers
90 views

Pagination algorithm based on scores

I need to divide scoreResult into pages (which is already ordered by score column from highest to lowest), and each page cannot contain too many records (e.g. 12 is ...
10
votes
2answers
68 views

Permutation of list in python so that list[x] != [x+1]

Basically I need to order a list, so that an element is not the same as the element that comes after or before it. For example [1,2,2,3,1,3,3] should come out as [3,1,2,3,1,2,3], [3,2,3,1,2,3,1] or ...
3
votes
2answers
67 views

Sorting a Stack in ascending order

Here's my implementation of sorting a stack in ascending order. The problem statement is as follows : Write a program to sort a stack in ascending order (with biggest items on top). You may use ...
10
votes
1answer
420 views

Bash command helper in C

Previously, I had written this program in C++ and asked about it here on Code Review. After spending some time with C++, I desired to become more familiar with its namesake. This is my first C ...
10
votes
1answer
94 views

Ford-Johnson merge-insertion sort

The Ford-Johnson algorithm, also known as merge-insertion sort (the name was probably given by Knuth) is an in-place sorting algorithm designed to perform as few comparisons as possible to sort a ...
-1
votes
1answer
41 views

Finding the minimum from a sorted rotated array with duplicates

Is this an efficient way of finding the minimum using binary search? ...
5
votes
2answers
120 views

String merge sort in Java

This snippet is about sorting a set of strings using merge sort. However, this version is tailored for strings as it relies on lcp values: Given two strings \$A\$ ...
4
votes
1answer
55 views

Order columns in R by substring

I want to order columns of a dataframe using a substring of the column name only. Suppose my columns are named ...
14
votes
2answers
103 views

IP sorting program

The purpose of this little program is to: Separate IPv4 addresses and IPv6 addresses Will be able to sort them even if the ...
5
votes
2answers
84 views

Counting inversions in C++ via mergesort and vectors [closed]

I have a text file that contains 100,000 numbers from 1 ~ 100,000 in an unsorted manner (no duplicates). The name of the file is "IntegerArray.txt" My task is to count the number of inversions in ...
7
votes
1answer
55 views

Constructing an odd-even mergesort sorting network

I was searching for a non-recursive odd-even mergesort implementation and found this one: Sedgewick R. The resulting sorting network is not an odd-even-merge sort network. When one draws a diagram ...
6
votes
3answers
78 views

Quicksort for strings in Java

I have this implementation of Quicksort for strings. The algorithm sorts the requested range by first character, then by second, third, and so on. (Please, do not confuse this with radix sort; it is ...
4
votes
2answers
69 views

Rails conditional sorting based on params

The following code sorts the current users bid model items based on a param condition :bid_status. It starts to get messy when checking if the project space (...
3
votes
2answers
76 views

Dynamic array sorting and storing program

I have written a program which closely resembles the way contacts are added and dynamically sorted in ascending order in your phone or other device. Though I have used ...
1
vote
1answer
33 views

A Simple SortableDictionary for JavaScript

First, I must humbly admit that I've been a developer for many years but I've almost never had to work as a front-end, Web UI developer. I've been given an opportunity to work for an organization as ...
4
votes
0answers
70 views

Selection Sort in Assembly [closed]

I was wondering if there could be anything done to clean up this code a bit. There is also a problem where every so often the sorted array will only display a fraction of the original amount of ...
3
votes
1answer
40 views

HackerRank: Counting Sort 1

I've just solved this challenge, though I feel that there is a problem with stack growth or something because the 5th testcase has a runtime error ...
6
votes
3answers
77 views

Sorting networks

Yesterday I read a fascinating article on Wikipedia about sorting networks. Comparator networks are abstract devices built up of a fixed number of "wires" carrying values, and comparator modules ...
1
vote
3answers
107 views

Merges two lists into one list

The code works as it is written, however; I was wondering if there are any easier or more effective ways to merge two lists. ...
3
votes
1answer
66 views

Comb sort in Java

Comb sort may be thought of as a generalization of bubble sort. The following is my implementation: ...
7
votes
2answers
232 views

Selection Sort in C++

I wrote a little C++ sorting routine for my Algorithm studies, but I feel that a lot can be skipped out. I am aware that modern sort takes Iterators and comparator functions, let's disregard that for ...
3
votes
1answer
74 views

Counting sort using arrays

This is my implantation of counting sort, but I see myself using way too many for loops. Is this necessary? ...
5
votes
3answers
221 views

Sorting a list based on date and time

I have a class that is used to basically store samples from data being read from a system. Within that class is a property that I use to store the date and time of that sample: ...
7
votes
3answers
83 views

Type-agnostic BubbleSort in C

I'm trying out different sorting algorithms for learning purposes, here I'm doing a "type-agnostic" BubbleSort. I modeled the function signature after the standart ...
13
votes
2answers
169 views

Exact sort - sorting with few move operations

A while ago, I found a somewhat interesting sorting algorithm named Exact-Sort, which is introduced with the following somewhat bold claim: No sort algorithm can sort an array with less position ...
6
votes
2answers
203 views

Ascending Order Algorithm

I wrote a simple function to sort an array of integers in ascending order. Here is the code - ...
1
vote
1answer
55 views

Merge sort in Clojure

I made my own version of merge sort: ...
4
votes
2answers
87 views

Remove duplicates in array

This function sorts an array and returns the unique items. I'm trying to get it down to a readable 5 lines of code. So far I've renamed the variable cursor variable and inlined the assignments. I'll ...
6
votes
1answer
91 views

Bash command helper in C++

I'm writing a program to help with remembering complex bash commands. On invoking the program, it asks for a description of the desired operation, e.g., "increase volume" or "find orphaned packages", ...
1
vote
2answers
82 views

Run-aware merge sort

The concept is very, very simple: let's do merging run by run (a run is a range without decrement). ...
2
votes
2answers
64 views

Improving Custom Comparator.compare() method

I have the class SeguimientoSeccion with this relevant attributes ...
6
votes
2answers
108 views

Project Euler 22: Names scores

Description of challenge: Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. ...