Questions tagged [sorting]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
107 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. ...
1
vote
1answer
42 views

A package for communications between packages - v2

This is basically the registry pattern and a pub/sub event system. Very simple and minimalist. Looking for general feedback. ...
2
votes
2answers
160 views

A package for sort algorithms - v2

Looking for general feedback and praise. This is for learning an not implementation as I would expect the built is sort algos to be much faster. Addressed issues here: A package for sort algorithms ...
3
votes
4answers
151 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 ...
5
votes
1answer
306 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
2answers
83k 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
374 views

Review my F# QuickSort Program

OK... last sort of the day and probably the most fun. F# is really awesome. ...
1
vote
1answer
1k 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
421 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
80 views

InsertSort F# program

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

Sorting an HTML table with JavaScript

The following code sorts an HTML table with JavaScript (without using any external libraries like jQuery). Are there any shortcomings or possible improvements I could make? ...
12
votes
4answers
29k views

Number aware string sorting with comparator

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
1k 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 ...
57
votes
4answers
194k 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: ...
2
votes
2answers
83 views

Query of users for some age, gender, and state, using a subselect

I have this query: ...
5
votes
3answers
376 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. ...
4
votes
1answer
3k views

Find missing numbers in a range, with duplicate numbers in a sorted array

Suggestions for cleanup and optimization request. This question is a follow-up question on this post. Lets assume the range of 1, 2, 3, 4. This function takes in an array of repeated ...
4
votes
1answer
2k views

Improving performance when sorting array of structs by multiple fields

I have an array of a struct containing 5 byte values. I need to sort this array by each value in a different order depending on the situation. These arrays are sometimes quite small (10-30 elements), ...
1
vote
1answer
7k views

sorting a numerical list using basic scheme

I would like some feedback on the appropriate way of ordering a numerical list using the most elementary scheme functions (sorry, i realise that elementary is not ...
2
votes
1answer
204 views

Visualization of bubble sort in progress

I've written a program showing the process of bubble sort arithmetic in C. I need some suggestions on improving it. ...
3
votes
1answer
3k views

Counting sort review

I've just wrote a program in C# for counting sort. space complexity is O(N+K) time complexity is O(N+K) I want reviews on my code and any better ways to implement this. ...
1
vote
1answer
307 views

MergeSort implementation with java.util.List passed as argument, not returned

I'm working on an implementation of MergeSort which sorts a List given as an argument. As follows ...
1
vote
3answers
218 views

Sorting integer array

Please check this program that sorts an integer array. It doesn't look very efficient. Please tell me how to correct this. ...
2
votes
3answers
777 views

How do you “sordid sort” alphanumeric strings?

The question is about sorting alphanumeric string in a "more natural" order. Source: Marc LeBrun's "Sordid Sort" Computist Quiz Often a system string comparison sorts alphanumeric data “unnaturally”...
8
votes
1answer
38k views

Implementation of Heap Sort

Is this the correct implementation of Heap Sort using Java? How can it be improved further? ...
1
vote
1answer
70 views

Sorting Each Entry (code review + optimization)

I have a requirement where there are 3 selection criteria user selects countries from a map displayed as lets say in 3 categories , i am maintaining 3 arraylist for the same.Each time he selects a ...
6
votes
4answers
722 views

A character array of arbitary length with 'R', 'B', 'W' is needed to be sorted in that order

There is a char array of n length. The array can have elements only from any order of R, B, W. You need to sort the array so that order should R,B,W (i.e. all R will come first followed by B and ...
0
votes
1answer
342 views

Sorting three numbers

...
5
votes
1answer
13k views

Merge Sort in C++

I've written this code for a merge sort, which is meant to implement the pseudo-code from Cormen's Introduction to Algorithms: ...
1
vote
1answer
287 views

Counting inversions

I'm trying to implement an inversion counting routine in Scala in a functional way (I don't want to port Java solution) but have real troubles with it. The sorting routine works fine but adding the ...
1
vote
1answer
126 views

Extracting Javascript functions

I have this jQuery click handler function that has three jobs: Set the time interval for the refresh rate Change the color on the clicked refresh rate selection Callback the tablesort functions to ...
1
vote
3answers
6k views

Optimizing bubble sort code

Please help me optimize this bubble sort code. It's working fine otherwise. ...
12
votes
2answers
565 views

Attempt at a sorting algorithm

I've been playing around and reading up on some sorting algorithms, and I've decided to try writing my own. It turned out to be quite fast (compared to the others shown in the image below). I'm very ...
4
votes
1answer
6k views

Implementation of quick sort in C#

I'm currently learning programming for the first time and I've created the following implementation of quick sort in C#. I basically read a very basic overview of how quick sort works recursively and ...
5
votes
3answers
8k views

Merge Sort Implementation

Any reviews/ways to speed up/general improvements for my Merge Sort? Maybe something to simplify it or add more to it? ...
1
vote
1answer
5k views

Merge sort with a linked list

I'd like this code reviewed. ...
9
votes
3answers
629 views

Beating built-in timsort with own count sort function

I am trying to write a count sort in Python to beat the built-in timsort in certain situations. Right now it beats the built-in sorted function, but only for very ...
5
votes
2answers
3k views

In-Place Quicksort in Python

Code is below. I'd like to know if this is a solid/efficient implementation of the in-place quicksort algorithm and if my Python style is good (I know there are no comments for now). Code is also on ...
2
votes
4answers
2k views

Sort a list in Python

My aim is to sort a list of strings where words have to be sorted alphabetically. Words starting with s should be at the start of the list (they should be sorted as ...
4
votes
4answers
2k views

My first javascript sorting

I started learning JavaScript a week ago, and I made a sorting function on my own. It does work, but I need reviews and how to write a better one. ...
7
votes
1answer
179 views

Out of order class resequencer

I got bored recently and wrote a tool to re-order out of order classes in Python files. This can occur with some auto-generation code tools for databases and the like; these files can sometimes be ...
1
vote
1answer
523 views

Implementation of insertion sort in Ruby, code correctness

To implement an insertion sort that sorts an array with optional block to determine sorting order, how can I improve this code? (Seeking best practices and code correctness) ...
2
votes
1answer
7k views

Implementation of insertion sort

Information about my code: I am following this MIT OCW algorithms course. The first lecture described insertion sort and merge sort. I implemented insertion sort in C. The algorithm is structured ...
2
votes
2answers
7k views

Simplest quick sort using one 19-line function

This will later be be posted on my website to explain quick sort so I would like how I could improve the readability and simplicity of this demo class. I do not like my use of the stack (meaning this ...
1
vote
1answer
1k views

Debug merge sort and validate comparison counters

I am posting the code for my merge sort to see if I can get folks offer suggestions as to where to make comparisons or if I am making the correctly already. I will post my heap sort and quick sorts ...
4
votes
1answer
1k views

Help with comparison counters in quick sort algorithm

At the suggestion of @templatetypedef, I am posting the code for my quick sort to see if anyone can offer suggestions as to where to make comparisons. And any tips on improving the code. I am using ...
2
votes
1answer
435 views

Sorting an array

I wrote this program for sorting an array of type String alphabetical without using compareTo() method so I am saying that if ...
5
votes
3answers
24k views

Linked List Sorting Algorithm

I was working on a sorting algorithm for my linked list implementation and wanted to get other people's input/comments/critique. What do you think of it in all aspects, including style? I was told ...
1
vote
2answers
2k views

Suggestions on improving Sorting Algorithm (Progress ABL/4GL)

I have written some sort routines for PROGRESS 4GL/ABL and wanting to get some input whether these sorts can be improved. And whether my sorts are true to name. And I would also be very interested in ...
1
vote
1answer
2k views

Lamba sorting for results

I have the List method that takes sorting parameter to sort results. The sorting parameter value is the same as the column name. ...