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

learn more… | top users | synonyms

0
votes
0answers
17 views

Merge Sort Variant: Using array link [on hold]

I was looking for the variants of Merge Sort. So my textbook says, A variant of function Merge in which No records need to be moved at all, can be implemented by use of an auxiliary array links. ...
11
votes
2answers
96 views

Allowing the user to alphabetize or randomize the contents of a text file

As a newbie programmer, I decided to try my hand at making a program whose function actually might be useful to someone, somewhere. This utility takes a text file, reads it out to the user, displays ...
0
votes
0answers
21 views

Radix sort (LSD) and Counting sort

I'm reading CLRS, and to practice, I rolled my version of radix sort and counting sort. I was looking at some reference implementations, particularly the LSD one from rosetta code, and mine performs ...
1
vote
0answers
23 views

Elegant way to sort on multiple properties that might be undefined

I'm trying to sort an array with JavaScript. The objects should be sorted based on several properties (about 4 in my real scenario), which are all strings that may also be null or undefined. A null or ...
3
votes
2answers
130 views

Sorting by patients' name or birth

Is there a way to write this simpler? ...
-1
votes
2answers
60 views

Sorting array with respect to two properties

I'm sorting with respect to Width and Length. However, Width has the significance ...
5
votes
3answers
84 views

Could this QuickSort be made more consise and “nicer”?

After seeing this example of a "primitive" QS implementation in F# by Scott W ...
6
votes
2answers
150 views

Merge sort using sentinels

This is my implementation of recursive merge sort, using sentinels: ...
6
votes
2answers
80 views

Python implementation of quicksort

My teacher often tells me that I don't take full advantage of Python capabilities, I would like to know if my implementation of Quicksort is good enough and how could I improve it, aside from doing it ...
5
votes
3answers
271 views

Avoiding label in a loop to sort links

How can I refactor my code to remove the label and the need for it? I am aware that a loop with label is "forbidden". But I can not find a way to rewrite this without the label. ...
5
votes
2answers
322 views

Shell sort seems inefficient

I am testing various sorting algorithms. Right now I am testing shell sort, insertion sort and selection sort. I ran all three algorithms on a randomly-generated list of 1000 integers. The selection ...
4
votes
2answers
69 views

Custom sorting a list of objects efficiently

I'm trying to make sorting of objects in my program as fast as possible. I know that sorting with a cmp function is deprecated in python 3.x and that using keys is faster, but I'm not sure how to get ...
2
votes
1answer
64 views

Mergesort and validation

I have written an implementation of a Mergesort in Python3. An Ideone with the implementation is available. Any suggestions for improvement or any criticisms? ...
2
votes
1answer
77 views

Quicksort implementation in Python

I have written an implementation of Quicksort in Python. I am new to Python. Any suggestions for improvement or criticism on my use of Python? ...
2
votes
0answers
52 views

Sorting an array to match the order of values of another array

I'm running hundreds of curl operations in parallel to my own API, the response array that I get is out of order ( the reason being that the first one to finish gets added to the response array ...
3
votes
2answers
82 views

Merge sort in Python

I've written a implementation of a merge sort in Python. It seems correct and I have tested it with this: ...
26
votes
2answers
2k views

Quicksort implementation seems too slow with large data

I've written a program to compare different sorting algorithms with the array size being 10, 1,000, 100,000, 1,000,000 and 10,000,000. I, of course, expect Insertion to win out on 10 and merge heap ...
2
votes
1answer
18 views

Sorting of nested categories inside a Common Table Expression

I have a PostgreSQL database which contains (among other things) the following table definition: ...
6
votes
2answers
152 views

Merge Sorting Lists

I'm fairly new to Java, arriving in the "future" from C and returning to type safety from Python. I'm looking for your suggestions to improve this code in the following areas: Correctness - are ...
5
votes
4answers
645 views

Arranging words in sentences alphabetically

For an online contest whose problem is here, I wrote some code. In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the ...
4
votes
1answer
76 views

Merge sort in Golang

I am just starting out with golang. I implemented the merge sort algorithm just to practice. Any suggestions or criticisms regarding the coding style? ...
0
votes
4answers
46 views

Speeding up script for processing three huge files

I have three huge files I need to process in order to rearrange the data contained within. The first file is a list of English example sentences (468,785 lines long). A typical line from this file ...
3
votes
2answers
79 views

Creating a list containing the rank of the elements in the original list

I don't really know how to explain what I'm looking for in a way that makes sense, but here goes: Say I have a list $$L=(4,7,9,10,6,11,3)$$ What I want to produce is a corresponding list $$ K = ...
7
votes
1answer
97 views

Sorting algorithms with utility functions and iterators

My implementation of insertion, merge, and quick sort, with some utility testing functions. I just wanted to know how I can improve the efficiency and general cleanliness of my code. (note: I know ...
9
votes
4answers
471 views

Sort three input values by order

This is a program to sort three inputted integers in order, from least to greatest. I would like to have it reviewed. ...
4
votes
2answers
212 views

Merge Sort an integer array

I've implemented merge sort an integer array. Is it okay to use i,j,k as variable name for looping? Should I change them to more meaningful names? Overall, any further suggestions on this code? ...
5
votes
2answers
63 views

Insert sort not working for large arrays

I've written an insert sort and for my assignment I must be able to sort an array of size 107. I've tested this sort with smaller arrays and it always sorts it correctly (up to size 105). If I make ...
3
votes
1answer
129 views

Count frequency of words in a string returning list of unique words sorted by frequency in descending order

I have the following solution but I am trying to optimize it to run in O(n) time, any thoughts? I first split the string removing any non-alphanumeric characters, then split the words using spaces ...
10
votes
2answers
512 views

Always sorted list

In this list, each newly inserted element is put in its place in order using IComparer<T>. The implementation uses a ...
5
votes
2answers
59 views

Pythonic quicksort algorithm

Is my implementation of quicksort efficient, in-place, pythonic ? ...
0
votes
1answer
90 views

Full counting sort on HackerRank [closed]

This is the full counting sort (CountingSort4) challenge on HackerRank. I've gotten it to the point where it passes every test case except the final one. I believe my algorithm is timing out due to ...
8
votes
2answers
97 views

Quicksort in Python

This is my first actual attempt at writing a Python program. I have a background in C++, so it was a big change (where's my iterators?), and I'm looking for criticism on my use of Python and its ...
2
votes
1answer
102 views

Binary HeapSort and Ternary HeapSort implementation

This is my take on binary and ternary heapsort implementation for a university assignment. The code works but I wonder if there are any mistakes or things to improve. ...
1
vote
1answer
44 views

HeapSort Efficiency

For heap (array based) sort, we need to start at index 1, ignoring the 0th index. If I want to make a static function like ...
2
votes
1answer
55 views

Sorting an int[] array using insertion sort algorithm - follow-up

Previous questions: Is my implementation of insertion sort is correct? Sorting an int[] array with an Insertion Sort I'm currently learning about different sorting algorithms and after reading on ...
1
vote
3answers
414 views

Faster way to check for a string in a array of string

I have a array of object, I need to sort them by time (hours, days or months) and separate the number of new IP. result is an array of object with property time (JavaScript timestamp), user IP ...
5
votes
1answer
54 views

Sorting an int[] array with an Insertion Sort

I'm currently learning about different sorting algorithms and after reading on the concept of the insertion sort of how it's done I've tried to implement it by myself before seeing how it was ...
2
votes
1answer
68 views

Is my implementation of insertion sort is correct? [closed]

I'm currently learning about different sorting algorithms and after reading on the concept of the insertion sort of how it's done I've tried to implement it by myself before seeing how it was ...
3
votes
2answers
121 views

Merge sorting linked lists

This works as expected and I want to get this code reviewed so that I can improve my coding ability. I am concerned about readability and the quality of the code ...
2
votes
2answers
60 views

Comparing two bubble sort algorithms

I'm learning C and I've got to a point learning about different sorting algorithms. Before seeing how it was done, I wanted to try doing it myself based on what I read on how it's working. ...
7
votes
3answers
247 views

Bubble sorting in C

I've been into algorithms lately, so I wanted to apply a simple algorithm using a language of my choice, which was C in this case. I've implemented the bubblesort algorithm (for strings) in a simple ...
4
votes
3answers
218 views

Merge Sort Implementation in Java (that seems slow…)

I decided to write my own implementation of merge sort. Here is the code: ...
5
votes
2answers
79 views

UniqueList Class in VBA

I often find myself abusing dictionary objects just for the exist method like this, ...
10
votes
2answers
279 views

Sorting an List of tiles based on size and row limitation

We are using the below code to optimally display our menu items (metro style). We are looping through an array of menu items and automatically shifting them based on size. Our tiles could be a size ...
5
votes
1answer
82 views

SortedSet of scored items

I want to return a set of items with an attached score to the user so that the user can easily iterate from highest to lowest and get the n-th highest items. Problems The JavaDoc of ...
0
votes
1answer
71 views

Reducing the sorting time of a large number of numbers

I have to sort many large numbers in a given time limit. The program below works, but not when the test cases reaches \$10^6\$, in which case it exceeds the time limit. ...
7
votes
2answers
141 views

External / File-based mergesort

I've implemented an external mergesort to sort a file consisting of Java int primitives, however it is horribly slow (fortunately it does at least work). Very little happens in the sort method: it ...
7
votes
2answers
321 views

Performing insertion sort in C#

This is my code in C# for performing insertion sort: ...
3
votes
4answers
649 views

Sorting Algorithms

A group of basic sorting algos. Based on Algorithms, 4th Edition - Robert Sedgewick | Kevine Wayne. Just making sure all of my logic and everything is correct. ...
10
votes
2answers
127 views

Sorting a collection

Related to, but not exactly a follow up of this question. After fixing some issues discovered in the last review, I added a little more functionality to the ...