Questions tagged [sorting]

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

Filter by
Sorted by
Tagged with
3
votes
3answers
1k views

Binary Tree Sort Algorithm (Python)

A Binary Tree Sort is an algorithm that builds a binary search tree from the elements to be sorted, and then traverses the tree (in-order) so that the elements come out in sorted order. Average Case ...
1
vote
0answers
10 views

HybridSort of QuickSort and MergeSort

I'll try to publish a paper about the programming language I've made (ArithmeticExpressionCompiler, short AEC) in Osječki Matematički List and, in order to demonstrate its usability for implementing ...
2
votes
1answer
26 views

SelectionSort Algorithm using Python

I am a rookie and I need help optimizing this SelectionSort() algorithm which I have tried using Python. ...
3
votes
1answer
30 views

Bubble Sort in Forth (for strings)

I wrote the following Forth code for sorting a string with the Bubble Sort method. It looks nice to my eyes, but I'd like your experienced opinion and any comments about the code you might have. In ...
3
votes
4answers
10k views

Sorting dictionary alphabetically

I have this method which successfully sorts the incoming dictionary alphabetically: ...
7
votes
1answer
256 views

Object-Oriented Sorting Algorithms

I would like a review of a library I've recently published. I realize this is a rather large request, but having looked on meta, it seems this is perfectly on-topic. I'll include a few choice samples ...
1
vote
0answers
31 views

Sorting Algorithm Visualiser in Javascript

I'm new to Javascript and Web Dev in general, so they'll likely be some conventions that I'm not aware of. I'm at an odds of whether to use Javascript's functional features more. In my opinion it's ...
2
votes
0answers
63 views

Python's quicksort algorithm

I was playing around with sorting methods, brushing up on my algorithms. I have made the following implementation of quicksort: ...
2
votes
1answer
59 views

How to sort and search in JavaScript large set

The array "scores" tells the total points for each person involved in a contest. So for example: ...
20
votes
1answer
2k views

Ford-Johnson merge-insertion sort

The Ford-Johnson algorithm, also known as merge-insertion sort (the name was probably given by Knuth) is an in-place sorting algorithm designed to perform as few comparisons as possible to sort a ...
-1
votes
0answers
20 views

Sorted Doubly Linked List with Comparable [closed]

I'm trying to create a Sorted Doubly Linked List with an Insert and Remove function. I've managed to create the Insert function, but I'm struggling to figure out how to remove elements. Also, I want ...
0
votes
1answer
37 views

QuickSort Algorithm (Python)

This is my implementation of Quick Sort Algorithm : ...
3
votes
2answers
16 views

Unscramble words faster in Python

So I'm currently using python to unscramble words that are retrieved from an OCR program (pytesseract). The current code I am using to unscramble words is this: ...
3
votes
1answer
33 views

Selection sort algorithm in x86_64 Yasm assembler

I returned to study assembly language. And this is actually my first function written in Yasm. Implementing this function is a suggested project from this book. I slightly modified the pseudo code ...
3
votes
1answer
72 views

Code for sorting items in recyclerView

I'm have recyclerView which is needed for displayed for show list of my audio records. I added the ability to sort my audio records. Please take a look at the code that I use for sorting and tell me ...
0
votes
1answer
52 views

Sort, & find out duplicates and missing elements in an array

this code is for return duplicates after sorted them, and also to return the missed value between the limits of the given array, it's executed correctly, but i need to optimize it so it excecute ...
3
votes
2answers
589 views

Python Merge Sort Implementation

I doing some algorithm reviews and am soliciting opinions on my implementation of the Merge Sort in Python. Anything from readability to optimization is fair game. In particular, I am wondering if ...
1
vote
1answer
46 views

Unscramble words faster in Python

So I'm currently using python to unscramble words that are retrieved from an OCR program, and checked in the 'dictionary'. The current code I am using to unscramble words is this: ...
2
votes
3answers
780 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”...
3
votes
0answers
64 views

Is this a topological sort? [closed]

I am trying to implement topological sort. The idea is that I have a vector of pairs in which the first element is indegree and the second is a linked list. I tried a bunch of tests, they seem to work,...
46
votes
10answers
86k views

Given an array of integers, return the smallest positive integer not in it

Write a function: function solution(A); that, given an array A of N integers, returns ...
4
votes
1answer
69 views

CLRS implementation (opportunity to sort subarray) of merge sort in golang

I'm reading "Introduction to Algorithms" by CLRS and I can't find an implementation of the pseudo code from the book in golang. By the original implementation I mean that we deal with extra parameters ...
5
votes
3answers
3k views

Sort characters in a Python string by frequency

I wrote a solution to the leetcode problem Sort characters by frequency and the solution passes 34/35 test cases. On the last test case, there is a "time limit exceeded" error with an input string of ...
1
vote
2answers
55 views

Comparing binary insertion sort with straight insertion sort in Java

Straight insertion sort When inserting an element into its proper location to the left, one can achieve that by \$n\$ adjacent swaps which totals to \$3n\$ assignments. Straight insertion sort, ...
2
votes
1answer
85 views

Searching and sorting ranges in excel with toggle buttons

I have a spreadsheet containing ±100 named ranges (5 rows, 15 colums) which are sorted based on time. My plan was to make toggle buttons to hide or unhide named ranges when they contain a certain ...
3
votes
1answer
55 views

Bubble sort visualization: JavaScript

I'm very new to the JavaScript, and hence I would like to get a feel on the language by writing some of the basic programs. One of those is the following visualization of the Bubble Sort: Code: <...
1
vote
1answer
62 views

Bubble Sort Implementation | C-ish and Modern C++

For practice purpose, I wrote bubble sort in C++ two styles: C-ish and modern C++ compliant. I would like to have your comments on any point on these implementations. ...
2
votes
1answer
36 views

Merge Sort Implementation Efficiency In Python

I wasn't able to find a standardized source for a working example of Merge Sort. Each learning site had a slightly different take on the algorithm implementation, disregarding the bottom-top ...
3
votes
1answer
43 views

Insertion Sort Implementation Efficiency

Is my approach to insertion Sort in Python efficient? What can be improved efficiency wise? ...
2
votes
2answers
33 views

Radix sort is deceiving

I wanted to compare radix_sort to quick_sort for values limited to 0..127 so I implemented this : ...
4
votes
2answers
81 views

Merge Sort in C

I implemented mergesort in C as an exercise. I have two main questions: Is the code future-proof? 2.1 Will I have problems modifying it to sort float and double? 2.2 What could be problematic for ...
1
vote
0answers
63 views

Reading 100,000 of data with loop and usort is too slow [closed]

The below code is meet to solve the question posted here https://stackoverflow.com/questions/61302983/in-a-meetup-schedule-algorithm-to-get-unique-and-available-date, but I can't post it as a solution ...
2
votes
1answer
242 views

Sorting function from a React app to display JSON data in a sortable table

I created this simple react application for a coding challenge, which is described in the linked README file. Basically, I created the components and helper logic to display dynamic JSON data in a ...
2
votes
1answer
89 views

C++ Sorting Filenames In A Directory

I wanted to have some advice about the code I have. I managed to get what I wanted done, but I do not think it is the "proper" way of doing it in the programmers' world. Could you help me improve ...
2
votes
1answer
74 views
4
votes
2answers
2k views

New Year Chaos JavaScript, needs to be sped up

Similar to this question but this is for Python Original problem with description on hacker rank I am currently trying to iterate through a large number of arrays and count how many times numbers ...
5
votes
3answers
3k views

Bubble sort in Haskell

The following code is part of my practice in implementing algorithms in Haskell. I'm aware that bubble sort is a bad choice for sorting sequences in real applications. ...
3
votes
1answer
64 views

C# Quicksort Assignment

For my CS minor I was assigned to implement the Quicksort algorithm in C#. I gave it a go and found that I like the implementation of the algorithm more than Mergesort. Now that I've got my Quicksort ...
1
vote
1answer
29 views

Heap selection sort in Javascript

I have (designed and) implemented this fancy sorting algorithm that combines natural runs in the input array with a heap data structure: ...
6
votes
2answers
592 views

Nearest Neighbor Algorithm (general nearest, forward-nearest, or backward-nearest)

I am trying to write an algorithm that can find user-specified nearest neighbors. By user-specified, I mean that the user can specify whether it's a general nearest neighbor, a forward-nearest ...
3
votes
1answer
66 views

Python implementation of Kahn's Algorithm

Please provide any suggestions on the below code for Kahn's algorithm. Can it be implemented in a better manner, or be improved: ...
3
votes
1answer
6k views

Bucket sort implementation

I want to optimize my code for performance and fine-tuned logic. ...
6
votes
2answers
331 views

Creating and listing a song collection

Songs Class: ...
5
votes
1answer
115 views

Tarjan's Algorithm Python Implementation

I'm planning to use Tarjan's algorithm for a program in which I would be processing a file, converting the processed data to a dictionary, doing a topological sort on that dictionary (using this ...
3
votes
2answers
94 views

My C++ sorting algorithm for vector

As I'm learning c++, I decided to implement my own sorting algorithm. As I'm a beginner I didn't use any template to be able to use them for different types of variable and they can only sort item in ...
5
votes
1answer
9k views

Directed acyclic graph with topological sort

I have here a class which represents a directed acyclic graph (Graph) and a vertex in the graph (Vertex). The vertices are ...
7
votes
1answer
113 views
3
votes
2answers
91 views

Heap Sort in Python

NOTE: I am beginner in Python I learnt the Heap sort today and tried my own implementation using Python. Can i get feedback for my code and areas of improvement. I have tried to add comments inline, ...
-2
votes
1answer
34 views
4
votes
1answer
92 views

Inserting Elements Into a Sorted Array

Very new to JS (wrote my "Hello World" around 3 days ago), but not to programming in general. My documentation is inspired by the approach I followed for Python (since I haven't learned JS ...

1
2 3 4 5
21