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

learn more… | top users | synonyms

0
votes
0answers
13 views

Sorting rows of matrix based on entries in first column [on hold]

I found a satisfactory sort algorithm (1D array) on the Internet, but I tried to retro fit it to bring the second column entry along with the first but the end result after compiling seems to sort the ...
3
votes
3answers
220 views

Can this insertion sort be optimized?

Could you provide feedback for this code? For arrays of length 2, is it more efficient not to use a sorting algorithm? ...
6
votes
3answers
84 views

Sorting three Decimal values

I have been given three values. @lLength, @lWidth, @lHeight. I need to take these ...
6
votes
4answers
173 views

Comparing pivot choosing methods in quicksort

I have seen various tweaks for quicksort and to establish their usefulness, I designed a program that randomly generates arrays and times how long quicksort takes to sort them. Right now I'm focusing ...
0
votes
1answer
33 views

Implementing a bubble sort on a linked list [closed]

I'm using the following prototype: Data* bubble_sort(Data *list); I'm trying to implement a bubble sort given a linked list of names. Note: this returns ...
-1
votes
3answers
111 views

Better sorting speed

import sys x=int(sys.stdin.readline()) lst = [int(sys.stdin.readline()) for i in xrange(x)] lst.sort() print lst How can I make this code faster for large ...
6
votes
3answers
251 views

Comparator based on Double values in Java

I have class point that represents point in 2D and I want to sort these points once based on their x-coordinate and second based on their y coordinate. Since x and y are double values my code looks ...
8
votes
2answers
327 views

Efficient way of sorting a List based on multiple properties using Google Guava

I'm using Google Guava 17.0 library. I have a class named AroundBust containing only two properties id of type ...
0
votes
0answers
38 views

Is my implementation of a merge sort correct?

I tried to get into programming several times but never did and never got very far past "Hello, World.", until recently when I found and read (most of, still don't get parts of it) "The Little ...
3
votes
2answers
61 views

Implementation of merge sort and bubble sort

I'm new to Go and looking for a review of my merge sort and bubble sort implementations. What can be done better? Can my code be cleaner/clearer? ...
2
votes
1answer
34 views

Search for data and order by priority efficiently

I have a search-function, that searches for specific data within a huge Object. Depending on how good a found entry matches, the finding gets "matchPoints" (or "Priority") ...
4
votes
1answer
46 views

Counting inversions

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count is 0. If array is sorted in reverse order that inversion ...
6
votes
2answers
143 views

Testing quicksort user input

I am testing a quicksort implementation. Arrays of random size with random data are passed to quicksort and the return time is averaged out. The user is prompted to enter values for minimum length ...
3
votes
1answer
46 views

Rebol Function to Categorize Items in a Block

I have a function that iterates through a block, tests each value against a given function and is placed in a block associated with the product of that function. ...
10
votes
3answers
543 views

Sorting numbers using Java Collections.sort()

Input is a file containing numbers in this format: 1.2 3 5.1 2 7 4 6 5 2 9.22 1 0.0 4 3 I am doing the sorting in the simplest way, using ...
7
votes
2answers
113 views

A Ruby sorting program for multiple criteria

This code review expands on an earlier one that deals with generating a football table from match data. This review deals with ordering said table based on several criteria. Your ...
6
votes
1answer
55 views

Algorithm for finding inversions in Merge Sort

Please help in code reviews for readability, optimizing it, functionality etc. ...
4
votes
1answer
49 views

Count array inversions merge sort

How does it look? Comments, code correctness, etc. ...
3
votes
2answers
60 views

Method for sorting numbers

I am new to jQuery and I want to know if there is a more efficient way to achieve this. I have an input with numbers 1, 2, 3, 4 and I want to change the order of this number dynamically according to ...
1
vote
0answers
40 views

Sort by value in multidimensional array

I have a multidimensional array of house properties: ...
4
votes
3answers
108 views

Sorting a flattened array

I'm using C# in .NET 4. The class holds an array of double that represents a 2-D rectangular matrix but (due to business requirements) must be stored flattened ...
3
votes
3answers
89 views

Merge Sorting in Python

This my implementation of the Merge Sorting Algorithm: ...
1
vote
2answers
84 views

Merge sort algorithm implementation using C++ (redux)

This is a follow up question to the one I asked a couple of days ago. I reviewed the suggestions & did some research (specifically, read relevant info on CLRS). The new version is 3 times ...
3
votes
3answers
73 views

Speed up counting sort algorithm in Ruby

I'm attempting this simple HackerRank counting sort problem but testcase #3, which has 100,000 test cases, is timing out. Is there something particularly inefficient about this code? ...
5
votes
2answers
195 views

Sorting an array in alphabetical order

I'm looking to get some feedback on this program I wrote - ways I could make it simpler or best practices methods. Chapter 7: Let's write a program which asks us to type in as many words as we ...
6
votes
2answers
279 views

Merge sort algorithm implementation using C++

I'm trying to learn proper C++ and algorithms at the same time. I particularly feel weird about my iterators usage in merge function. Is this a good way to handle ...
3
votes
2answers
63 views

How might we make this Python Merge Sort implementation more Pythonic?

I've implemented a (version of) Merge Sort algorithm in Python. My goal here is two-fold: Improve understanding of Merge Sort and recursion in a language agnostic way. Improve understanding of ...
2
votes
2answers
94 views
6
votes
2answers
441 views

Stable custom alphabetical order using List<T>.Sort

Background This is a problem from a programming contest. The Sharonians of planet Sharon, at the far end of our galaxy, have discovered various samples of English text from our electronic ...
1
vote
3answers
60 views

Activity by length

I was having a hard time finding out how to make this any faster. I broke down the code that I am playing with into more methods than necessary to try and see where things could increase. Can anyone ...
3
votes
1answer
58 views

Sort 3x3 grid by rotating 2x2 subgrids

This question originates from this post. Anyway, I'm trying to solve the following problem: Given a 3x3 grid with numbers 1-9, for example: 2 8 3 1 4 5 7 9 6 I ...
2
votes
3answers
82 views

Implementing the merge sort with only arrays, out of place

This has been asked a few times here, but I was wondering what I could do to improve the efficiency and readability of my code. My programming skill has gotten rusty, so I would like to elicit all ...
2
votes
2answers
109 views

Quicksort implementation in C#

Okay, so I'm a self-taught programmer and have been brushing up on all the 'boring' bits that CS students do that most of us self-taught ignore. Things like Algorithms and Data Structures ...
2
votes
5answers
409 views

An acceptable way of sorting List

I had a problem where I needed to find the largest amount of passengers in multiple cars/vans etc, so I got the totals from each vehicle and added them to a list, I then created this method to sort ...
2
votes
1answer
108 views

Merge Sort optimization

I was looking at other people code and I realized that mine is not so neat after all. In this version, I included a base case for the merge part (when there is only 2 elements to merge, just sort it ...
3
votes
1answer
55 views

Is there a better way to return values with merge sort?

I have been attempting to learn Scala lately and so have produced a couple of different sorting algorithms to build up my basics. I think I have been lucky with the methods returning exactly what I ...
6
votes
2answers
1k views

Count frequency of words in a given file

Write a function that takes two parameters: a String representing a text document an integer providing the number of items to return Implement ...
2
votes
1answer
69 views

Quick sort implementation in JavaScript in prototype style

I have implemented quickly the quick sort algorithm in JavaScript using prototype based style. The code is rather short (http://jsfiddle.net/b8mfY/): ...
3
votes
1answer
63 views

Insertion Sort implementation in Java

I have implemented Insertion sort in Java. Please review it. ...
8
votes
2answers
58 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
62 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
53 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
313 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
215 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: ...
7
votes
1answer
100 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
423 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
76 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 ...
10
votes
1answer
481 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
687 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
95 views

Merge sort could work 10 times faster

I am implementing merge sort in Java and I have a performance problem in this method: ...