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

learn more… | top users | synonyms

3
votes
1answer
37 views

Insertion Sort implementation in Java

I have implemented Insertion sort in Java. Please review it. ...
-1
votes
0answers
27 views

Pseudo code bubble sort [on hold]

I would like a hand check done on this, to understand exactly how the computer is changing each variable. ...
7
votes
2answers
38 views

In place quicksort

I implemented my own sorting in VBA because it doesn't provide its own, and it's healthy to test yourself. It was surprisingly difficult and I ended up make a few tweaks that I didn't expect to make ...
8
votes
1answer
39 views

Sort function to sort item numbers separated by colon

Below is my code. This is a function that will be applied as a sorting method to a grid based data set. The data in the column to be sorted can be stuff like: ...
4
votes
2answers
45 views

Multicriteria sort array javascript

I have an array of objects that I must sort based on two criteria. I've come up with a solution but I'd like to know if there is a better way to do it. Assume a list of devices: ...
11
votes
3answers
206 views

Insertion Sorting in C++

From Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, ...
9
votes
1answer
142 views

QuickSort C# Implementation

It has been a while I haven't implemented a QuickSort and I wanted to write it down like I remembered. Here it is: ...
6
votes
1answer
53 views

Generic radix sort

This started out with my answer to Radix Sort on an Array of Strings?. Since I intend to write a generic radix sort for my own purposes anyway, I continued a little bit, and here is a version tested ...
11
votes
4answers
245 views

Least significant digit (LSD) radix sort of strings

I am learning string algorithms and wrote this C example based on a Java example I found online. Any feedback relating to style, code clarity, whether it is generic enough to be re-used, interface, ...
4
votes
1answer
61 views

Is this Shell sort?

Trying to learn shell sort, I kinda understood what wikipedia was trying to say, but I wanted a bit of confirmation, so I went on youtube, here, but this code does not work and does not look like what ...
9
votes
1answer
147 views

Bubble Sort in C: Array vs Linked List

A few weeks ago I posted a code review of a linked list so I decided to implement bubble sort on my journey of learning C. Here is the referenced linked list library, though this isn't really what's ...
3
votes
1answer
83 views

Google Maps Javascript API v3: Sorting Markers with Check Boxes

Recently I built a map with custom markers (pins) and a sorting function to display each by type (Member, Supplier, Prospect, New Member). The HTML (check boxes wired up with ...
6
votes
1answer
87 views

Merge sort could work 10 times faster

I am implementing merge sort in Java and I have a performance problem in this method: ...
5
votes
2answers
173 views

How to verify if HTML table sort is stable or not?

I have implemented a HTML table sorting. I actually implemented a sort first using jQuery and then modified it based on the answer to this question for performance as I had done the same mistake. My ...
3
votes
0answers
38 views

Sorting a PHP array in a discontinuous manner

I start with an array containing some 'ids' and some 'values'. What I need is to organize the 'ids' in a new array to be, if possible, apart when the 'values' they are associated with are alike. So ...
1
vote
1answer
81 views

Why is my Bubblesort implementation faster than my Quicksort code?

Here is my Bubblesort code: ...
3
votes
1answer
45 views

Time optimization of counting shifts in insertion sort

Is there any way of counting how many shifts would it take to count shifts while doing insertion sort? This is a Hackerrank problem. Here's my solution, but it takes more than 16 seconds. ...
7
votes
2answers
125 views

How can I make my isSorted function faster?

I made an isSorted function in Scala and Java as well and when I measured the time of functions' run I saw that the Scala version was very slow. It ran about 3.2 ...
3
votes
1answer
50 views

Sorting possibly unstable and general jsfiddle/jquery problem

I have a simple sorting algorithm that I was told is possibly unstable. I'm wondering what in the sort is unstable. I have test cases written to test all fields with no issues. A secondary problem is ...
4
votes
1answer
38 views

External “bucket” sort

I'm working on a CTags plugin for Sublime Text. One of the open issues revolves around the fact that an in-memory sort of a tag file can cause some form of memory or buffer overflow errors (the stack ...
5
votes
1answer
67 views

Quicksort implementation

I put together this implementation after playing around with various partitioning- and pivot-strategies, and it runs fine. I wrote this off a version which seemed a bit different from the majority of ...
7
votes
4answers
158 views

MergeSort performance

Do you see any inefficient parts with the following code? On internet I see 30 ms for 100.000 integers but I can sort 100.000 integers in 300ms. The data is random. I am using late 2013 macbook pro so ...
5
votes
1answer
54 views

How can I speed up my shell sort?

I'm trying to implement a bunch of sorting algorithms in JavaScript, and I can't figure out why my shell sort is so slow. It's 6x slower than my merge sort, and only slightly faster than my insertion ...
2
votes
2answers
96 views

Produce a nearly sorted (or K sorted) array

Given an array of n elements, where each element is at most k away from its target position, devise an algorithm that sorts in O(n log k) time. For example, let us consider k is 2, an element at ...
5
votes
1answer
101 views
3
votes
1answer
74 views
7
votes
2answers
81 views

Is this quicksort efficient and acceptable?

In order to complete one of my assignment I needed to include a quicksort so I was wondering if this is correct and acceptable. The code: ...
2
votes
1answer
407 views

Approximating/Sorting groups of dates into buckets + general JS patterns/style

Update: I've updated the code below pretty extensively and posted a new question over here. I'm working on a directed study project with a professor of mine helping him build out a Django based ...
2
votes
2answers
241 views

Merge Sort Algorithm in Python

Implementing basic sorting algorithms to learn them, and coding, better. Criticisms/ critiques welcome. Also possible optimizations. ...
2
votes
2answers
188 views

How to sort two array of objects using Underscore.js?

I am sorting 2 arrays of object like this, but I know this is very bad. Any good approach, like using each method like so? ( I tried, but using each, I am unable to return the object ) ...
7
votes
2answers
230 views

Sorting a set of numbers in a file using Java BitSet

I have implemented a program to sort a file consisting of numbers. The program generates a different output file with all numbers sorted in it. I have implemented this program using BitSet. I wanted ...
4
votes
2answers
104 views

Insertion Sort Algorithm in Python

Implementing basic sorting algorithms to learn them, and coding, better. Criticisms/ critiques welcome. Also possible optimizations. ...
3
votes
1answer
134 views

Selection sort algorithm in Python

I'm learning basic algorithms and implementing them in Python. Critiques needed/welcome. ...
11
votes
6answers
587 views

Help refactor this to be less procedural and more recursive

Reference: Is this a faithful rendition of the selection sort algorithm? I'm working through an elementary book on sort and search algorithms, and writing some sample code to test my understanding. ...
9
votes
3answers
485 views

Bubble sort algorithm in Python

I'm starting to implement basic sorting algorithms. Criticisms on the implementation is welcome. ...
6
votes
1answer
176 views

How do I make this duplicate sort algorithm run faster?

I've written a program whose code is included at the end of the question. It is working fine but the performance time is approximately 5 minutes and 29 seconds. I am dealing with 1090 images. This ...
5
votes
1answer
50 views

Shorten a sorting function

I have this function: ...
2
votes
1answer
79 views

A package for sort algorithms - v3

Addressed both issues in this codereview post. Fixed the indexing issue and the call mechanism of the function expression. Looking for perfect code. Hope this is the last rev. ...
3
votes
4answers
130 views

A package for sort algorithms

I'm trying to learn basic algorithms which are typically taught in an introduction to CS course, which is usually taught in a compiled language like Java. However, I want to focus on JavaScript, so I ...
4
votes
1answer
72 views

Is this an efficient merge sort implementation with regards to average time complexity in Big-O notation?

Is my below merge sort implementation in O(n log n)? I am trying to implement a solution to find k-th largest element in a given integer list with duplicates with O(N*log(N)) average time complexity ...
5
votes
3answers
512 views

Inputting and sorting three integers

The problem to the question is: Write a program that takes 3 integers as an input from the user using input dialog messages and sorts the three numbers. I just want to know: is there any major ...
1
vote
1answer
118 views

Review my F# QuickSort Program

OK... last sort of the day and probably the most fun. F# is really awesome. ...
1
vote
1answer
93 views

Merge Sort Program

I have written the following program to implement merge sort in F#. Can you please review this and let me know how can I write this in the most functional way (also most efficient and concise)? In ...
1
vote
2answers
44 views

Review my F# BubbleSort Program

I have written this code for BubbleSort in F#. Can you review and let me know how I can do this in most functional way. ...
4
votes
2answers
49 views

InsertSort F# program

I have written this InsertSort program in F#. It works, but I am not very happy with it. ...
5
votes
2answers
4k views

How should I sort an HTML table with Javascript in a more efficient manner?

The following is my own code to sort an HTML table with Javascript (without any external library like JQuery). I’ll be glad if experts in the field show me the shortcomings of my code along with the ...
5
votes
3answers
709 views

Number aware string sorting with comparator Java

I have this class for use in sorting strings such that if strings have a number in the same position it will order the numbers in increasing order. Alphabetical gives: file1 file10 file2 What I'm ...
4
votes
3answers
75 views

Sorting strings in a one dimensional array

What are the better solutions possible? I have a character array with different strings. There is a max size for the strings. In case a string is smaller than max size remaining places are filled ...
5
votes
3answers
972 views

Grouping elements in array by multiple properties

During work, I was given this task: to group elements with similar properties in the array. In general, the problem is as follows: ...
5
votes
3answers
119 views

Trying to cut down redundancy in my code

I have created a class that has many methods for sorting an ArrayList of objects. Each method is somewhat similar in that they employ some kind of sort on an ArrayList and then return the arrayList. ...