Most voted "classification" questions
Sorting algorithms are used to lay out the elements of a given list in a certain order defined according to a desired parameter.
Learn more…290 questions
Sort by count of
-
4
votes1
answer142
viewsSort in C++ does not show the correct input value
I made a code to read 3 values, and with the sort() it sorts the values in ascending order and just below shows the input values. For example:-14 21 7 it sorts right but the output shows -14 7 21 //…
-
4
votes3
answers801
viewsExplanation of the function and application of the javascript Sort function
I know what the function below is for (return the candidate with the highest number of votes), but I do not understand the functioning of the function sort, passing another function. Does anyone…
-
4
votes2
answers594
viewsWhat is Java Sort?
Every programmer know that a list of arrays are printed in an orderly way, but in the middle of the way sort(). The result of the impression was this: Abacaxi Banana Laranja Manga I thought it would…
-
4
votes1
answer76
viewsArray Ordering with Value Exchange
Good Afternoon! I have assembled an array that receives 9 records from a single variable and the values are displayed on the user screen. However, when trying to put this matrix in ascending order,…
-
4
votes1
answer134
viewsConcatenate files according to the order of the list C#
I have a program that concatenates PDF files. First it does the SPLIT of all pages of each file and store them in a temporary folder. When I press the end button, it calls a function GetFiles() that…
-
4
votes2
answers193
viewsDefine criteria for sorting a list of lists
I have a list of lists of strings. For example a list, in which the internal lists have size n=3: listEx = [['verde','preto','laraja'], ['rosa','lilás','azul'], ['bordô','cinza','branco'], [preto,…
-
4
votes3
answers341
viewsSort a list based on two different criteria using Sorted
I have a list of tuples and I want to sort them out, but that’s two different criteria. Each tuple has the following configuration: (peso, beneficio) The ordination I want to make is as follows:…
-
4
votes1
answer60
viewsHow do I keep an original copy when using Sort in Javascript arrays?
I need to sort an array, but I can’t miss the original sequence. To do this, I created a new variable and assigned the value to it, making a copy of the original. However, when using the method…
-
3
votes2
answers91
viewsRefine article ranking based on views of all articles
The idea is to ascertain the reputation of a particular article based on the views of all existing articles. An article can have a reputation of 1 to 5 stars, the same being constantly changing…
-
3
votes2
answers180
viewsSql - Natural Ordering - Varchar
Situation I need to perform Natural string ordering. Example Processo 1 Processo 2 Processo 3 Processo 10 Processo 11 Processo 12 Standard Order. (ASC) Processo 1 Processo 10 Processo 11 Processo 12…
-
3
votes1
answer181
viewsOrganize list based on an integer value of its elements
I have a ArrayList of a class of mine that contains variables String and integers, as a name and punctuation. When I display it through a Adapter I would like the list to be in descending order, but…
-
3
votes2
answers129
viewsSorting Doubt - C Language
I am ordering a simple vector, increasingly. The code works. But the next line that got me confused: if (matriz[i] < matriz[j]) Why is the sign there smaller, not bigger? If I want to change…
-
3
votes2
answers67
viewsProblems with Sort() and knockoutjs
https://jsfiddle.net/n8v3hj5n/1/ I’m having trouble ordering a knockoutjs observableArray, every time I order the list it gives a turn effect(). Who asks to solve this problem?…
-
3
votes1
answer260
viewsWhy does a Sort method not work properly on LINUX servers?
I have a question, I have a function to order a array which has names of accentuated persons (UTF-8). It works properly on WINDOWS servers, but when I launch the code to run on LINUX servers the…
-
3
votes2
answers1618
viewsSort array by key, being a string
I have a random array containing in its keys, an alphanumeric sequence. Using the function ksort, get the following result: array(22) { ["A1"]=> string(2) "A1" ["A10"]=> string(3) "A10"…
-
3
votes1
answer762
viewsChained list - sort by selection
I am playing a sorting algorithm by selection using chained list. I’m using two loops using a min cell, i and j, with respect to cell j, ok, but at the time of changing the min pointers and i is not…
-
3
votes2
answers141
viewsSort Mysql results using two tables
is the following, I have two tables, a so-called topical and other comments(which has a foreign key from the topical table), I wanted to list the topics by sorting them by the amount of comments…
-
3
votes1
answer90
viewsSort products interchange according to flag
I have a model called Product which has, in addition to product data, a flag featured that says whether the products are featured or not. When mounting the view the products should be displayed…
-
3
votes1
answer196
viewsHow does callback sort functions work internally?
In php, when we want to order a array in a customised way we can use the function usort. I know that for this function to work, we must use values 1, 0 and -1. In case, if I wanted to order this…
-
3
votes1
answer2985
viewsStd::Sort with comparison function
Studying a little about the STL I came across the function std::sort which may receive a comparison function. template< class RandomIt, class Compare > void sort( RandomIt first, RandomIt…
-
3
votes1
answer1231
viewsSorting of string and number vectors
I’m having a problem with a college exercise. Basically it’s a shop system, where I come in with the amount of stores, the amount of products, the name of the products, and the amount of products in…
-
3
votes1
answer225
viewsDelegation of events to dynamically generated elements
I will try to be more specific. I have a list <ul>which is populated via jQuery: var $imovel = $("#lista-resultados-pesquisa"); $.ajax({ type: 'GET', url: 'imovel.json', success:…
-
3
votes2
answers63
viewsRandom numbers appear later in sorting algorithm
At the end of my program the result is giving random numbers, which occurs? main(){ int i; int a[10]; int x; int aux; for (i=0; i<10; i++){ printf ("Entre com os numeros %i: ", i); scanf ("%i",…
-
3
votes2
answers316
viewsjson_encode returns the asort() order
The method asort() is used to sort arrays, without losing the index. I sort both the SQL search and the array. However, when sending the data via JSON (using json_encode), he rearranges the keys.…
-
3
votes1
answer63
viewsWhat is the parameter passed in Sort()
Doing an exercises I came across the following parameter passage in sort(): let notas = [7,6,10] notas.sort((a,b) => a < b ? 1 : -1) console.log(notas) I could not understand, since I have…
-
3
votes2
answers916
viewsOrderby with ng-repeat nested in the Angularjs
I need to order a list, which is in two ng-repeat, but I can only order within the group of the second ng-repeat and made a jsFiddle that shows my code: https://jsfiddle.net/xxg4ajkk/2/ The order I…
-
3
votes1
answer358
viewsSort lists with multiple parameters using lambda expression
Given the class Ponto, the function ordenar sort the list elements by the following criteria: first value in x, afterward y and finally value in z. Okay, the code works. But I’d like to understand…
-
3
votes1
answer127
viewsTypes of ordering and their performance, which one to choose?
I know of various forms of ordination such as Selection Sort, Bubble Sort and Quicksort, we also have PHP functions like sort() and array_multisort(). Currently the system I developed works with…
-
3
votes1
answer202
viewsWp_query, How to sort the meta_query in the order of an array?
I’m developing a system where I have a Deck presentation. I have a field that picks up the post by the suit of the type copas being within the array specification meta_value, and would like it to be…
-
3
votes1
answer98
viewsWhy when ordering a list with Sort(), returns None?
The following script sorts a dictionary: d = {'a': 10, 'g': 15, 'c': 67, 'z': 90, 'e': 144} ordenada = list(d.keys()) # gera uma lista das chaves do dicionário (protegida por uma tupla)…
-
3
votes1
answer510
viewsBest worst case sorting algorithm
I want to know which algorithm has the best performance when dealing with its worst case compared to others dealing with each with its own worst case, all applied in array ordering. To better…
-
2
votes3
answers81
viewsOrder of posts when consulting the database of my CMS
I am developing a Site with CMS. Everything works perfectly just that I would like the latest posts to be at the top of the page. What’s happening now is that the last posts go to the bottom of the…
-
2
votes2
answers110
viewsSorting does not work
I had to implement my own Sort, using Selection Sort. However, the simple code (I analyzed several times, and for me it is correct) gives strange results. template <typename T> void…
-
2
votes1
answer130
viewsInput bugging for no reason
I made a program that computes (by a DB itself using fstream) patients of a hospital. It has functions to output (one only for ostream using the iomanip and another to ofstream and fstream) and…
-
2
votes1
answer174
viewsSorting data from one column to another
I am setting up a hierarchy and everything is working correctly, I just have a small problem, in the ordering of the data. Follows the structure of the table. (as basic as possible) create table…
-
2
votes1
answer335
viewsHow to make a Sorting in classes?
Funny thing is, that was an answer! The problem I have is this: I have a Person class, which initializes with a string, and it splits into a number and another string. After the class is mounted, I…
-
2
votes1
answer983
viewsHow to measure time complexity of sorting algorithms?
Given a sort algorithm, for example burble Sort, how to measure its run time? For example, let’s say that the input of the vector or list has a size of 1000 elements, what is the time measured in…
-
2
votes1
answer14856
viewsHow to organize random integer values in descending order in a Java array?
I need to organize the values that the array receives randomly and leave them in descending order, but honestly I don’t know how to do it, there’s my code, I couldn’t organize. package…
-
2
votes1
answer106
viewsSorting an Array
I have my class ItemList public class ItemListPropaganda { private int iconeRid; private String texto; private int valor; public ItemListPropaganda(String texto, int iconeRid, int valor) {…
-
2
votes1
answer2432
viewsSort at the lowest price in a Mysql table
How to list products that have the lowest price for the highest! From smallest to largest! Using PHP and Mysql.
-
2
votes4
answers38774
viewsSequential numbering of query results
I’m not really close to the database, and actually I don’t even need such functionality, but just out of curiosity, it’s possible to create in Runtime, that is, during SELECT, a sequential numbering…
-
2
votes0
answers81
viewsSort in array with two dimensions in VBA
I have a array two-dimensional dynamics with: Dates of birth in the first dimension (column) and names in the second dimension: Example: Minhaarray(0,0) = "01/05/1990" Minhaarray(1,0) = "Luisa…
-
2
votes0
answers103
viewsSort chained list in MVC standard project
In my project I am using my own chain list implementation, that is, I am not using the ready list of the Java API. In addition, my implementation is of a generic list, which has Object objects on…
-
2
votes1
answer221
viewsData sorting: Bubble Sort or Collections Sort method
Which is more efficient to sort a large amount of data passed through an array: Bubble Sort Using the own resources of Collections, for example the method Sort.…
-
2
votes1
answer266
viewsIs this Bubble Sort correct?
People I’m reading book "Programming Principles and Practice using c++ (2nd Edition)" from C++ creator. There is an exercise there at the very beginning talking to do a program that sorts the data…
-
2
votes1
answer3763
viewsHow to remove Duplicate Objects in an Arraylist?
Hello I have an arrayList of objects. however these objects end up repeating themselves, so I wanted a naneira to remove duplicates. I’ve tried using Hasset, but it doesn’t seem to work with…
-
2
votes1
answer119
viewsUsing the Sort() method
Guys I have this following js code: var livro = { ISBN : '978-85-7522-347-5', titulo : 'Aprendendo a Desenvolver Aplicações Web', preco : 83.00, autor : 'Semmy Purewal' }; And I need to write a…
-
2
votes2
answers125
viewsSort two-dimensional array by date index (timestamp)
I got the following array that contains file information from a folder: Array ( [name] => Apresenta__o1.ppt [server_path] => C:\wamp\www\portais\arquivos\alunos\4_45258\files\Apresenta__o1.ppt…
-
2
votes1
answer873
viewsdo Sort of a file with multiple columns
Hello need to do a Sort of my file, I have 3 columns: the first would be the chromosome (1,2,3,4,5.28,W,Z), the second would be the position on this chromosome and the last would be values. When I…
-
2
votes1
answer107
viewsData sorting with php
I need to sort an array by a specific "order" field, where within that array I have banners objects with the id, order, name and img fields. I need to sort this array in order. the order banner 0…