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

learn more… | top users | synonyms

2
votes
0answers
35 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: ...
0
votes
0answers
19 views

Recursive BubbleSort Not Working [on hold]

For some reason my recursive bubblesort function won't work anymore. This was a homework assignment that I had worked when the homework was due, but now I'm getting what looks like a memory error. ...
24
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
13 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
129 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
522 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
40 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
30 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
72 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
66 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
383 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
151 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
52 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
71 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
500 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
53 views

Pythonic quicksort algorithm

Is my implementation of quicksort efficient, in-place, pythonic ? ...
0
votes
1answer
71 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
90 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
71 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
39 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
45 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
384 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
52 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
48 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
85 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
59 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. ...
5
votes
3answers
198 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
148 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
73 views

UniqueList Class in VBA

I often find myself abusing dictionary objects just for the exist method like this, ...
10
votes
2answers
269 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
75 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
90 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
279 views

Performing insertion sort in C#

This is my code in C# for performing insertion sort: ...
2
votes
4answers
620 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
116 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 ...
3
votes
3answers
116 views

A practical example of evenly distributing n lists into a single list

I had previously asked about how to evenly distribute the items in n lists into a single list and was referred to this question. I made a practical example of my solution for this in VBA for Excel, ...
8
votes
1answer
115 views

Sorting Visualizations - WinForms

Description I think many many people have seen this youtube video "15 Sorting Algorithms in 6 Minutes" When I saw it, I decided: "I can do that better" and I tried to get things done with the tools ...
7
votes
2answers
98 views

Merge sort in JavaScript

I implemented this merge sort in JS and noticed that for random integer numbers it's a lot faster than the build in sort functions of all the browsers I tested (Chrome, FF, IE). Does anyone have an ...
5
votes
3answers
86 views

Merge Sort implementation in Java

Can you check my merge sort implementation? From all of my testing it seems like it works, but I just wanted to make sure I am doing it as good as possible, and it couldn't be optimized any further. ...
2
votes
3answers
93 views
0
votes
3answers
25 views

Determining if integers are sorted

I have this task to find whether 5 integers are ordered from the smallest to the largest or not. Depending on the results, the program output should be "yes" or "no". No loops or arrays supposed to ...
2
votes
4answers
92 views

Java sort by selection: which is better in regards to readability and efficiency?

Which algorithm do you think is better in regards to readability and efficiency? selection(): ...
7
votes
3answers
407 views

Ticket management system

I am building a ticket management system for a state server we use at work. Back end is node.js with multiple front ends. I am rewriting my back end to be more maintainable as the scope grows. For ...
2
votes
1answer
62 views

Insertion sorting an int array

I'd like to improve this Insertion sort code ...
7
votes
5answers
442 views

Checking if an array is sorted

I've come up with two ways to check to see if array is sorted and return true if it is. ...
4
votes
1answer
46 views

Potential quicksort optimizations

I implemented qsort() like this. I was wondering what improvements I could do to make it better. ...
0
votes
3answers
93 views

Selection sorting an int array

I'd like to improve this selection sort code ...
6
votes
3answers
760 views

Bubble sorting an int array

I'd like to improve this bubble sort code ...
3
votes
3answers
237 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? ...