Python: compare and sort tuples in list

I'm trying to sort a list of points (their IDs). The tuples are a result of a minimum spanning tree (using networkx) of a graph in which every node is connected to every other node, but their weights differ. I need to extract a (shortest) path for ea...
more »

2017-04-18 19:04 (1) Answers

How to sort list in R?

I have list of lists similar to this: a <- list( list(day = 5, text = "foo"), list(text = "bar", day = 1), list(text = "baz", day = 3), list(day = 2, text = "quux") ) with unknown number of fields and the fields my be out of order. how...
more »

2017-04-18 18:04 (2) Answers

Why my filtering and sorting is not working?

I have an array of object event where each event has a start date and an end date. I am trying to filter the events by removing any events that are older than now. Then, I am trying to sort my events as most recent to then display them on the screen...
more »

2017-04-18 16:04 (2) Answers

c++ read from a file and output sorted content

I am learning to code and found interesting task, but i do not know where to start in solving it. So i have a file with some titles and comments which need to be placed under the right title. So the first line of the input contains a number N which d...
more »

2017-04-18 16:04 (1) Answers

Save/Alphabetize XML Responses in a Foreach Array

I'm new to php and am doing this project to teach myself a bit. I'm importing XML data from a Reuters RSS feed and would like to sort the content of all the responses alphabetically. I've had no problem loading the information I want to the page us...
more »

2017-04-18 15:04 (2) Answers

Python sorting deep in a datastructure

I'm in pretty far over my head right now for Python scripting and don't really understand what I'm doing. I have a dictionary where the keys are strings and the values are lists of strings. I need to sort the strings within the list alphanumerically...
more »

2017-04-17 23:04 (2) Answers

Custom sorting and calling for columns in R

Got 100 columns with currency data not sorted in a specific order. However, there is one column of spot rates and one for forward rates for each currency. They can all be identified by their name which are in the format USDXXX (XXX=ticker for currenc...
more »

2017-04-17 22:04 (0) Answers

Yii2 gridview sorting

I have a problem: I can't sorting my gridview. When i click on "Product name": In URL i can see : index?sort=-product_name but nothing happens. I did not use CRUD generator. Controller public function actionIndex() { $searchModel = new CompanyP...
more »

2017-04-17 19:04 (1) Answers

Linked List Implementing Sorting Method

i made the linked list its not from java collections and i put in it many methods .. my linked list worked like the original one but theres a small differences my class have a print and sort methods my input is : [5,18,3,10,2] ... or it can be a stri...
more »

2017-04-17 10:04 (1) Answers

Sorting the list by alphabet ascending order

my code below doesn't work, and I can't figure out why. It compiles well, but the result doesn't seemd to be sorted. import java.util.*; class SortByName { public static void main (String[] args) { List<String> nameList1 = new ArrayLis...
more »

2017-04-17 09:04 (6) Answers

Working with CSV file

I've been working and trying to solve this problem for maybe a whole week, which at this point I am wondering if I can solve it without it diving even deeper into the C# language, and I'm quite fairly new to C#, as well as working with CSV files and ...
more »

2017-04-17 00:04 (2) Answers

Get Ordering from Ordered in Scala

Is there any way, given an object with the trait Ordered, to get an Ordering which uses the same comparison as the original object? The reason I want to do this is I have implemented a merge sort with the following signature (the Manifests are just ...
more »

2017-04-16 18:04 (2) Answers

Sorting Algorithm in Groups in JavaScript

Quick question. I have the "list" variable and it looks like this: var list = [ { appid: '753', contextid: '6', assetid: '3351193666' }, { appid: '255710', contextid: '6', assetid: '4141511622' }, { appid: '255710', contextid: '6', assetid: '435...
more »

2017-04-16 16:04 (4) Answers

std::sort by unary mapping

The C++ standard library offers to pass a Comparator to std::sort. However, I have many cases in my code where I want to sort a list of T objects by a function f. A comparator like this would be a valid option: bool compare(const T& a, const T&a...
more »

2017-04-16 15:04 (2) Answers

Array Rotation with $_session for All user

When a file is accessed it will appear 1, as refreshes appear 2, and in refrest reappeared 3, and so on. I use $_SESSION but when it's applied rotation different array in each user/browser, I want when user A accessing the php file appear 1, and...
more »

2017-04-16 05:04 (2) Answers

How to sort array based on the numbers in string?

Given this array = [ "3ab1", "2a0", "1abc2" ] How do I sort it to [ "1abc2", "3ab1", "2a0" ] (descending order of the last number) and return [ 1,3,2 ]. (the first numbers of each term) When the last number and the next last number is not consecu...
more »

2017-04-16 02:04 (4) Answers