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

learn more… | top users | synonyms (1)

2
votes
1answer
22 views

Create a text index of files

This program creates a text index of 3 different files in Python. While this works correctly, I am still a beginner in Python. I used a list of class objects. Can this code be further optimised? ...
1
vote
0answers
27 views

Heap selection sort - follow-up

See the previous and initial iteration. I got rid of Run objects and just maintain two integer arrays in the RunHeap: one for ...
2
votes
3answers
72 views

Bubble, selection, and insertion sorting

The following programs are bubble sorting, selection sorting and insertion sorting. As most of the programs online or in books are with Arrays and not ...
0
votes
1answer
33 views

Sorting object with null values underscore sortBy

I'm sorting my object by its property ActivityOrder, which will sometimes contain null values if the user has not explicitly ...
3
votes
0answers
47 views

Sorting colors by the name of the color

I was in need to sort Colors, so the first thing that I tried was this: ...
5
votes
3answers
121 views

Finding k largest (or smallest) elements in an array

I have written this code for the question: Finding k largest (or smallest) elements in an array My approach uses a temporary array. Please suggest any ...
5
votes
2answers
56 views

Optimising a user's-choice sorting algorithm

With the help of some nice folks at Stack Overflow, I wrote an algorithm that will give a user three buttons: option a neither ...
4
votes
1answer
63 views

Heap selection sort in Java

See the next iteration. I designed and implemented this adaptive heap sort in Java. It works as follows: Copy the range to be sorted into auxiliary array \$A\$ Create an empty run heap \$H\$ Scan ...
2
votes
1answer
43 views

Sort files by the type of file

I need to sort files by the type of the File. To accomplish the task I first wrote the code below: ...
3
votes
5answers
121 views

Sorting ArrayList

Here is the task: Create several classes of flowers that extend abstract flower. all fields -- random. make a bunch of 20 different flowers calculate the price of the bunch sort ...
2
votes
1answer
100 views

Bogosort vs bogobogosort [closed]

A question on Stack Overflow had me look up the article on bogosort on Wikipedia. There they describe the bogosort algorithm and the bogobogosort algorithm. They say, about this last algorithm, that: ...
3
votes
2answers
153 views

Measure execution time of sorting algorithms

I have to measure execution time of certain sorting algorithms being passed as functions in following program. I also do not have to measure it on random container but also on ascending as well as ...
4
votes
1answer
105 views

Counting number of inversions

This is a HackerEarth Challenge Problem. Question: Puchi hates to carry luggage, but unfortunately he got a job to carry the luggage of his N friends in office. Each day, one of his N ...
-1
votes
2answers
94 views

Quicksort for Objective-C

This is quite plain vanilla, but I'm hoping for Objective-C specific feedback. Also I'd be interested in what folks think about sorting in Objective-C vs. doing all sorting in C or C++ (and which?) ...
5
votes
2answers
57 views

HeapSort implementation

I have implemented the heap sort algorithm which passes my tests. Although, I would like to ask you if I can improve anything from readability to performance. ...
5
votes
3answers
112 views

Recursive and iterative approach for mergesort

Problem: Question 8: * Mergesort is a type of sorting algorithm. It follows a naturally recursive procedure: Break the input list into equally-sized halves Recursively sort both ...
-2
votes
0answers
29 views

Bottom up mergesort in Java - follow-up

See the previous and initial iteration. Now I have rather more cohesive code: BottomUpMergesort.java: ...
2
votes
1answer
47 views

Sorting an associative array alphabetically

I am using a foreach loop to sort an associative array alphabetically. I would like to know if there is a more proper and/or efficient way of doing it. The array: ...
5
votes
0answers
36 views

Finding most frequent words from Google N-Gram dataset

I have written a program to process Google 1-Gram dataset in order to obtain the list of most frequent words. This is my second more or less working program in Haskell, so I really want to know if it ...
6
votes
1answer
71 views

Multiprocess Bogosort

I only program by hobby, and I'm trying to improve with Python, so along with practicing coding I decided to venture into multiprocessing. This is a command line and will sort a variable number of ...
2
votes
1answer
50 views

Sorting an integer array using heap sort

I have written this program to sort an array using heap sort. Please review it for further improvements. ...
1
vote
2answers
62 views

Function to sort items with an array of keys

I'm working on a function to sort two elements using several properties. I want to know if the function is well structured. ...
4
votes
3answers
166 views

IComparable implementation for a class representing a version

I have an UpdateId class which represents some kind of version (like AssemblyVersion). UpdateId has three int values (listed in their compare priorities order): Year, ReleaseNumber and Revision. How ...
2
votes
1answer
64 views

Bottom up mergesort in Java

See the next iteration. I have this iterative mergesort (a.k.a. bottom-up mergesort). BottomUpMergesort.java: ...
1
vote
2answers
156 views

Sorting an Integer array

The program sorts the array from lowest to highest and outputs the index of the searched value: ...
6
votes
1answer
69 views

Topological sort

The algorithm works in steps: Produce the graph in the form of an adjacency list e.g. this graph 0 - - 2 \ 1 -- 3 produces this adjacency list ...
5
votes
2answers
408 views

Is the list sorted?

Is the trade-off between simplicity and performance worth it? ...
4
votes
4answers
105 views

Increase performance of a method which finds the element removed from an array

Imagine that you have a TreeSet of numbers, and you copy them into an array, but you remove one element of it. You want to know the element removed. ...
0
votes
2answers
78 views

Big O notation for quicksort implementation [closed]

I am trying to find out what would be the Big O notation of a quick sort implementation I wrote. If I can get some analysis on the code, that would be great. ...
5
votes
1answer
58 views

Implementation of ApplySort method from IBindingList

I am currently developing a family of keyed collections, and I wanted to have one which would implement the IBindingList interface. My ...
4
votes
2answers
133 views

Two functions to impose order on queries

I am writing a c# program to build generic sort algorithm on a request to a collection of data. The data needs to be sorted based on the supplied columns.I am using Entity framework and Expression ...
4
votes
1answer
96 views

Sorting a list of names by greatest lexicographical order

This is a puzzle I found online that I have been trying to optimize and make the best version. I've tested it and it works great but I'm curious how it can be improved in any way. Instructions: ...
2
votes
2answers
97 views

Beginner implementation of Merge Sort

This is my first time implementing a merge sort (just getting started with algorithms & data structures). Are there any obvious things I have done wrong? I am also worried that I have overused ...
10
votes
5answers
1k views

Sort three numbers using only if-statements

Beginner here, trying to make a small program that sorts three numbers from smallest to largest only by using ifs. Any thoughts on how to improve this? ...
34
votes
3answers
3k views

Sorting millions of integers

Last Friday I was hit with a sorting interview question that I never really had to deal with. Develop a your own sorting algorithm. It cannot use any other Classes for help. It needs ...
6
votes
2answers
68 views

Bubble sort in Ruby

For practice, I tried implementing Bubble sort in Ruby. I wasn't very sure how nested for loops would look like in Ruby. Is this the 'right way' to do this in Ruby? I found this question, but it looks ...
1
vote
1answer
48 views

boost::spreadsort for std::pair

Boost 1.58 has new library spreadsort, so I tried it out. I wrote simple sample for sorting vector of pairs of int: ...
2
votes
1answer
28 views

Reducing a 2D array to its longest unique series that aren't contained within any other

I have an array whose members are arrays containing strings. Each array has 5 elements, some of which may be empty but always at the end of the array. The order of the strings matters because their ...
2
votes
2answers
91 views

Merge Sort algorithm

I just read and experimented with C++ implementation of the merge sort algorithm from the Wikipedia page. During the experiments I have slightly modified the source code and would like to know how ...
2
votes
1answer
112 views

Treesort in Java

I have this sorting algorithm which constructs an (unbalanced) tree and performs in-order traversal in order to sort the requested range. However, the more order exists in the input array, the closer ...
0
votes
1answer
49 views

Sorting algorithms - Relocation Counter

I want to count the total relocations for each of these sorting algorithms. From the results it seems my code is correct, but I need someone to confirm it. Is the counter variable placed in the right ...
3
votes
1answer
277 views

Create a struct to store student data and perform statistical analysis on data

I had to create a program that had a struct that held data inside of it. I had to read an input file and take the contents and read it into an array of structs. Then, I had to solve for some ...
2
votes
4answers
145 views

Printing all the permutations of a string in alphabetical order

It is a code eval challenge question https://www.codeeval.com/open_challenges/14/. My answer was accepted, and I modified my code again to improve it. Please let me know is it possible to improve it ...
3
votes
1answer
90 views

Modern C++ compliant insertion sort

This is a kind of follow up to my previous sort implementation question with specific questions to insertion sort, and Modern C++ idioms. Anybody seeing this post can see how I got to this modern ...
1
vote
1answer
160 views

Modern C++ compliant selection sort

I am writing, as review, Modern C++ compliant versions of sorting algorithms I previously have seen. This post is about selection sort, and selection sort only. Whilst selection sort is rather ...
5
votes
2answers
88 views

Performance of Median routine using min performs abysmally

I am writing a routine to calculate median using the minimum of the numbers and then changing the value of the minimum to a large value outside the range of numbers (assuming you know the nature of ...
7
votes
4answers
1k views

Bubble sort algorithm in JavaScript

I'm new to JavaScript (and programming) and taking a course. I was tasked with creating a bubble sort on any array using JavaScript. Of course, since this is an algorithm challenge, no sort method ...
1
vote
1answer
80 views

Natural mergesort

This is a problem from Robert Sedgwick's Algorithms book: Write a version of bottom-up mergesort that takes advantage of order in the array by proceeding as follows each time it needs to find two ...
2
votes
0answers
85 views

Nuts and bolts algorithm

I am trying to learn golang. This is a problem from Robert Sedgewick's Algorithm's book: You have a mixed pile of N nuts and N bolts and need to quickly find the corresponding pairs of nuts ...