Questions tagged [sorting]

23319 questions
1

votes
0

answer
43

Views

C++ overloaded [] operator with sorted array

I have class called Vector which contains dynamic array with numbers. But array must be always sorted. I have a few methods like changeSize, addElement, etc. but the only problem is overloaded array operator. It must return particular number to read or write. This is my code: double &Vector::operato...
Atof
1

votes
2

answer
6.7k

Views

OrderBy pipe in angular 4

I'm trying to write sorting pipe according to code in this link: http://www.advancesharp.com/blog/1211/angular-2-search-and-sort-with-ngfor-repeater-with-example Although I have trouble with dealing with undefined values. My pipe works correctly on columns where there are not any undefined values. B...
przemlat
1

votes
3

answer
78

Views

Why MongoDB is fetching documents from disk after a sort even when the used index contains all fields on the query

Apparently MongoDB is fetching all documents from disk to be able to fulfill a query after a sort. To illustrate the issue we can insert the following documents with a progress and a date into a foo collection: db.foo.insert({ '_id' : 1, 'progress' : 'A', 'date' : ISODate('2017-12-01T07:52:40.831Z')...
1

votes
2

answer
43

Views

Group value via range and value sql query

I have two table . Table1 have following fields. From To id ---- ---- ---- 0 0 1 1 5 2 5 10 3 10 15 4 Table 2: Table 1 ID Value --------- ------- 1 10 2 10 3 15 4 10 current output...
ila
1

votes
2

answer
72

Views

Combine columns and sort the values before creating a new column

I am making a python script that I want to combine several columns of string data and sort them alphabetically before creating the new column. To simplify my example here is a really simple example of the format of the data I am dealing with: Ingredient 1, Ingredient 2, Ingredient 3 pickles, beef, m...
Marcel
1

votes
0

answer
58

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 value. So when I select the toggle button for 'Opel' for instance, all the named ranges containing 'Ope...
Tommy
1

votes
0

answer
23

Views

What is the correct way of sorting NSFetchedResultsController values?

I have NSFetchedResultsController and I want to sort the values in it alphabetically. And I want to use it later as: if let myItems = frc.object(at: indexPath) as? MyItem { ... } I'm trying to sort it like this: var new = frc.fetchedObjects?.sorted(by: {($0 as! MyItem).name < ($1 as! MyItem).name})...
J. Doe
1

votes
0

answer
82

Views

Pandas Erratic Sorting by DateTime column

I have a pandas dataframe, and after reading some comments (thank you) would like to clarify. I have defined my BeginDate column as data['BeginDate'] = pd.to_datetime(data.BeginDate) data = data.sort_values(['BeginDate'], ascending = [False]) by printing type(data['BeginDate']) it returns BeginD...
Frank Drin
1

votes
0

answer
164

Views

Trouble using UILocalizedIndexedCollation to filter a table view with the inputed user's name.

I'm new to this forum! I am having a little bit of trouble sorting my Person's array with the use of UILocalizedIndexedCollation. Code I created the following class: @objc class Person : NSObject { @objc var firstName: String! @objc var lastName: String! init(firstName: String, lastName: String) {...
ozark
1

votes
0

answer
93

Views

Ordered Isoline Calculation from 3D Triangular Surface in MATLAB

I need to extract the isoline coordinates of a 4D variable from a 3D surface defined using a triangulated mesh in MATLAB. I need the isoline coordinates to be a ordered in such a manner that if they were followed in order they would trace the path i.e. the order of the points a 3D printer would foll...
M.Thomas
1

votes
1

answer
58

Views

Store data sorted into new table

Good afternoon all, I have two columns that I am trying to sort into a table, memberid and then total spend. When I run the following query: Select Memberid, totalspend from Table order by totalspend; my data returns the way that I expect it to. When I try and run: Select MemberID, TotalSpend into...
Richard2018
1

votes
0

answer
96

Views

SIGSEGV error occurs when I sort the inner string of the word

I am doing the coding challenge on Codewar which is about sorting the inner string in descending order. Problem description: For example: 'wait for me' -> 'wiat for me' The string will never be null and will never be empty. It will contain only lowercase-letters and whitespaces. My solution is that...
Kelvin Ng
1

votes
0

answer
57

Views

JavaFX - Sorting Algorithms - BarChart not updating

Here is a hope that someone might be able to help me. I have to work on a project for sorting algorithms and have had to develop an application which uses an interface, so that a sorted list is updated on the Console, a ListView and this 'Bargraph' (a subclass of BarChart). The project has the foll...
Cameron
1

votes
2

answer
109

Views

String sort for buckets in aggregation elastic search

I want to sort the result by field that has string value, for example, I have responded like this 'aggregations': { 'group_agg': { 'doc_count_error_upper_bound': -1, 'sum_other_doc_count': 82, 'buckets': [ { 'key': '38:16:33:6A:71:FF', 'doc_count': 1, 'group_agg_top_hit': { 'hits': { 'total': 1, 'm...
qusai safa
1

votes
1

answer
37

Views

Clustering 'Like' records yii2

i am attempting to create a table for my client that has a bunch of records of a type, and i need to create a record of a 'child' type which inherits most of its fields from its parent, and that i have done. now i need to use Gridview to display that information but the child records need to be clus...
Andy
1

votes
1

answer
60

Views

Enable sort for wpf DataGridColumn which source is converted value

In my wpf/c# project I have datatype with 3 dimensions: length, width and depth. When user inputs those in datagrid the volume for this item is calculated in 4th column using converter. What I want is to enable sort for this column. I tried to put SortMemberPath to Converter return value, but this d...
Andrew Miller
1

votes
1

answer
495

Views

Excel VBA, pop-up window to define range to perform multiple criteria sorting

amateur macro writer here. I am looking for some guidance in how to write a macro which does the following: Pop-up box which prompts user to define a range of data e.g. A26:K35. Use this range to then perform a custom filtering e.g. Sort on Column A, then B, then C in ascending order. The following...
PMH123
1

votes
0

answer
51

Views

Finding subsets of a set of points that are all a maximum distance from each other?

I have a csv file with the following format: thing1_id, thing2_id, similarity The similarity is between 50 and 100. I've filtered out all pairs with similarity less than 50, but I do have the full set where the lowest is around 25. There are duplicate comparisons at the moment, i.e. thing1-thing2 is...
hm527
1

votes
1

answer
26

Views

Sum 2 columns and sort it with DESC and only showing 1 records only with prioritizing first inserted(the smallest id)

Hello i know my actual question it's look like a bit complicated, so first i have student +------------+------- +---------+ | id_student | score_a|score_b | +------------+--------+---------+ | 1 | 70 |80 | +------------+--------+---------+ | 2 | 70 |90 | +--...
KRISBIANTORO PRABOWO
1

votes
1

answer
485

Views

Asp Core, How to use PagingList<T>.CreateAsync() with a viewModel?

I am working on a asp.net core 1.1 project and i want to create paging in my some views. I studied microsoft documents about paging in asp core but it is very simple mode with 1 table. In my view i use multi table and use a viewmodel to initialize it. I want to use PagingList.CreateAsync() method to...
saeed
1

votes
1

answer
158

Views

sort and give value to a two dimensional object in a class based on value of another object c++

I am going to sort a two dimensional vector object in a class based on values of another object in the class. My class looks like this: class problem { public: vector> bit; vector> WaitingTime; vector processingJob; } problem1; const int i=3; const int j=4; I want to sort the 2...
1

votes
2

answer
118

Views

Sorting a list of pairs C++

I am building a system which should take a in a list of pairs, both strings, and sort them into the correct order. In the list they appear: E,F C,D B,C A,B D,E and the output should be A,B,C,D,E,F The system is given a random letter to start with, then iterates through the list and gets the correct...
TRV
1

votes
1

answer
925

Views

Angular ViewChild custom sort selector

I'm learning about angular ViewChild currently, but I seem to be missing something when using ViewChild to select custom reference variables from the DOM. In my template I have two tables: I am attempting to target them with a sort for each: @ViewChild('eventTable') eventTableSort: MatSort; @ViewChi...
Broc Broccoli
1

votes
1

answer
72

Views

Sort the table on header click which has both number and String as column value using AngularJS

i have one table which has dynamic data and i should be able to sort in asc /desc each column based on odd or even click. i have added following code $scope.sortdata=function(column){ if($scope.sortcolumn!=column) $scope.reversesort=true; $scope.sortcolumn = column; $scope.reversesort=!$scope.rever...
Hema
1

votes
1

answer
25

Views

active record sorting by two columns at same time (not one, then the other)

So I'm stumped on this one. I know this is dumb example, but it gets the point across. Lets say I have a model called cars and there are three columns, personal, business, and color. The first two columns hold license plate numbers, and the last one obviously the color Now I want to display this mod...
Jim Kilborn
1

votes
0

answer
48

Views

How to sort an ElasticSearch index using a field inside an array?

I need to sort documents in my elastic index using a field inside an array in that document. Document structure looks like this, { 'name':'xxxxx', 'comments':[ {comment: 'xxxxx', 'commentDate':'yyyy-MM-dd HH:mm:ss', 'id':1}, {comment: 'xxxxx', 'commentDate':'yyyy-MM-dd HH:mm:ss', 'id':2} ] } What...
Isuru Pathirana
1

votes
1

answer
704

Views

Radix Sort & O(N log N) Efficiency

I have been learning about Radix sort recently and one of the sources I have used is the Wikipedia page. At the moment there is the following paragraph there regarding the efficiency of the algorithm: The topic of the efficiency of radix sort compared to other sorting algorithms is somewhat tricky...
Levenal
1

votes
2

answer
88

Views

pandas data frame sort

I have a pandas dataframe like this which I try to sort by column 'dist'. The sorted dataframe should start with E or F as per below. I use sort_values which it is not working for me. The function is computing distances from 'Start' location to a list of locations ['C', 'B', 'D', 'E', 'A', 'F'] and...
Florian
1

votes
1

answer
24

Views

Google chart ordered by stack height

I'm trying to reorder my chart after inserting some data from a json file. I've tried to sort the data array without success. There's any plugin or easy way to reorder the stacks and show the tallest first? Heres my code: var ChartHelper = { data: [], labels: [], datarray: [], init: function() {...
Bruno Sousa
1

votes
1

answer
474

Views

MRJob Sort in Python

I have an assignment that requires me to use mapper/reducer in python to complete a MapReduce for customer data. I have a CSV file with the CustomerID, ProductID, and the Amount Spent. The first task is to determine for each customer the total spent, which I easily completed. The next part requires...
Rebecca Sue Wood
1

votes
0

answer
138

Views

How to sort an ArrayList based on another ArrayList order

So I have 3 different ArrayList`s which I need to sort to update my RecyclerView. final ArrayList Coin = tinydb.getListString('Coin'); final ArrayList Day = tinydb.getListDouble('Day'); final ArrayList Price = tinydb.getListDouble('Price'); I sort my Price list like this: Collections.sort(Price...
1

votes
2

answer
1.1k

Views

Ultimate Date/Time Sorting Plugin For Jquery Datatables with Moment.js

I am trying to sort a specific column in my jquery dataTable by datetime but am running into some trouble. I included the moment.js and datetime-moment.js libraries and initialized my format but it is still not sorting correctly. It seems to be sorting by string instead of datetime. my javascript is...
FrankTheTank
1

votes
1

answer
110

Views

D3 bar chart sorting - axis label sorting logic explanation needed

I've build bar chart with sorting on click: https://codepen.io/wawraf/pen/gvpXWm. It's based on Mike Bostock's chart https://bl.ocks.org/mbostock/3885705. It works fine, but when I tried to build it from scratch I realized there is something i do not fully understand: Line 72 contains following func...
wawraf
1

votes
1

answer
166

Views

Sorting array, and selecting field in MongoDB using Java

I'm trying to transform the following data using MongoDB aggregation. I want the array 'connections' sorted and I only want the array-elements that have a name matching my regex. In this case I want the array sorted on 'steps' (number of intermediare friends) and only those with 'Han' in their name...
Kadetje
1

votes
1

answer
31

Views

sql query needs a specific order by

My query without any order will result in: owner parent target key value operator childOP ----- ------ ------ --- ----- -------- ------- 267582 6 19 0 0 4 -1 267582 6 19 0 267582 32 4 267582 6 19 0...
Andreas B
1

votes
1

answer
133

Views

Rotating line sweep - sorting edges

I'm trying to implement Lee's visibility graph. There might be n number of polygons, where each side of the polygon is an edge. Let's say there is a point p1, and a half-liner parallel to the positive x-axis start at p1. I need to find edges that are intersected by r, and store them in sorted order...
Lukas Povilonis
1

votes
2

answer
46

Views

how can I sort by one row

maybe it is a very naive question but I could not figure it out I have a data like this df
1

votes
1

answer
300

Views

Why is the complexity of merging M sorted arrays linear time?

Suppose we want to perform external sort and have M number of blocks sorted, where each block contains k comparable items such that n = Mk. k in this case also refers to the maximum number of items you can fit into memory for sorting, and n is the total number of items to sort. Then using the merge...
oldselflearner1959
1

votes
0

answer
39

Views

How to sort HashSet by HashCode()

HashSet hs= new HashSet(); Employee e1 = new Employee('Tatha',20,6000); Employee e2 = new Employee('Amar',30,9000); Employee e3 = new Employee('Aziz',25,15000); Employee e4 = new Employee('Tatha',20,6000); hs.add(e1); hs.add(e2); hs.add(e3); hs.add(e4); how to sort by EmpID? in hashCode() method
Tathagata Mukherjee
1

votes
1

answer
25

Views

Sorting a php array column by custom order

I have an array of arrays: Array ( [0] => Array ( [a] = 1, [b] = 'ABC', [c] = 'ABC', [1] => Array ( [a] = 2, [b] = 'DEF', [c] = 'DEF', [2] => Array ( [a] = 3, [b] = 'JKL', [c] = 'JKL', how can i have my array become like this: Array ( [0] => Array ( [b] = 'ABC', [a] = 1, [c] = 'ABC', [1] => Array...
Galang Re

View additional questions