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
27 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 ...
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
64 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
60 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: ...
0
votes
1answer
37 views

QuickSort Algorithm (Python)

This is my implementation of Quick Sort Algorithm : ...
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 ...
3
votes
1answer
34 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 ...
0
votes
1answer
53 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 ...
-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 ...
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: ...
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
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,...
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 ...
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, ...
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 ...
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 : ...
3
votes
1answer
43 views

Insertion Sort Implementation Efficiency

Is my approach to insertion Sort in Python efficient? What can be improved efficiency wise? ...
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
64 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
94 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 ...
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: ...
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 ...
6
votes
2answers
331 views

Creating and listing a song collection

Songs Class: ...
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 ...
3
votes
1answer
68 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: ...
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 ...
7
votes
1answer
117 views
-2
votes
1answer
34 views

Selection sort in C

...
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
0answers
56 views

Construction of external sorts from comparison ones

Here's an example how to construct an external sorting algorithm from the Quicksort. The method may be applicable to other known internal comparison sort algorithms. I have checked that it shows N*...
10
votes
3answers
3k views

My approach to sorting algorithm

For practicing purposes, I had the idea of making a sorting algorithm in Python. My approach to it was to iterate through a given unsorted list to find the shortest number in it, add the number to a ...
1
vote
1answer
88 views

Novel sorting algorithm

I have devised a novel sorting algorithm, named Oracle Sort, which I believe is far superior to all currently known sorting algorithms (under certain assumptions). It utilizes an oracle to achieve a ...
1
vote
1answer
61 views

Simple sorting algorithm speed

I was working on an assignment in my Python class to sort 10 numbers but I wanted to be able to sort any set of numbers be it large or small. The assignment didn't really cover any sorting algorithms ...
2
votes
3answers
720 views

Sorting a list in ascending/descending order with a button toggle

I have this piece of code written as a function to handle a button-toggle for sorting a list in ascending and descending order. Below is the code which is working as expected, but I would appreciate ...
-1
votes
2answers
62 views

sort a list with equivalence classes [closed]

I'm trying to optimize the following function f, written in python. It is a function of an integer k. First it calls another ...
2
votes
2answers
87 views

Sorting multiple vectors based on a reference vector

I am trying to sort vectors based on a reference vector. First I am getting the indexes for the reference vector and then using that I am doing inplace sorting for the rest of the vectors. ...
4
votes
0answers
79 views

Rust Iterative and Recursive Merge Sort Implementation

I'm in the process of learning both Rust and algorithms after primarily focusing on web development. As such I've had a go at implementing merge sort both iteratively and recursively. I've looked for ...
1
vote
2answers
985 views

Bubble Sort and Selection Sort (C)

I used the "long" form of all math statements, avoided the use of pointers, and used only while loops for aesthetic purposes (simply put, I think the code is prettier when it is written like that.) I ...
4
votes
0answers
53 views

Opinion on a small app I created using JavaScript

Recently I created a small app using JavaScript, and I would love for some JavaScript developers if they have the time of day, to tell me their opinions so I can grow and improve. I'm mostly working ...
6
votes
1answer
203 views

Animation of sorting algorithms

I have created a visualisation of sorting algorithms using tkinter and matplotlib. Please let me know what you think and if you have any suggestions or find errors. The aim of this code is to create ...
4
votes
1answer
138 views

Reverse quick sort in Fortran

I have written a quick sort routine to inplace sort an array in descending order: ...
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 ...
6
votes
5answers
253 views

Implemented command-line based merge-sort algorithm. How can I make the code efficient, robust, maintainable, secure?

This is follow up question regarding merge-sort implementation to the previous post. Recently I have implemented a command-line argument based merge-sort sorting algorithm. Format for command-line-...
2
votes
2answers
59 views

Bubble Sort with tests

I've become a bit rusty in Java. This is an attempt at brushing up my skills. Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the ...
3
votes
2answers
53 views

Reduction of time for the code of sorting RGB and Depth images according to timestamp values

I have RGB Images, Depth images and OpenPose Images(generated from RGB Images). The number of RGB and Depth images are different so I have to find the exactly which RGB images corresponds to which ...
2
votes
2answers
90 views

Merge sort implementation in python 3

I have implemented a Merge sort in Python 3, and it works well. If anything needs to be improved, I would appreciate the criticism. ...
2
votes
1answer
124 views

Timsort implementation in Python

I wanted to implement a Timsort in python. Here's what I've come up with: ...

1
2 3 4 5
21