## How to sort a batch of 2D tensors in tensorflow?

I have a tensor A with the shape of [#batch, #MaxSequence, #Features], where the actual lengths of the 2nd dimension (may be less than #MaxSequence) are stored in a tensor L. I want to sort A by the 2nd feature in the 3rd dimension on the sequence in...
more »

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

## How to Sort array alphabetical and by strlen

I am looking for the cleanest ways to sort array alphabetically and by strlen in PHP. The cleanest way i came up with to sort by strlen is this: array_multisort(array_map('strlen', \$array), \$array); How would i extend this to sort alphabetically b...
more »

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

## How to sort array of string by length and maintain their keys in PHP?

There is an array of strings; \$arr=array('longstring','string','thelongeststring'); so the keys are: 0=>'longstring' 1=>'string' 2=>'thelongeststring' I want to sort it by length of strings, from longest to shortest, but without chang...
more »

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

## Array merging and sorting complexity calculation

I have one exercise from my algorithm text book and I am not really sure about the solution. I need to explain why this solution: function array_merge_sorted(array \$foo, array \$bar) { \$baz = array_merge(\$foo, \$bar); \$baz = array_unique(\$baz); ...
more »

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

## Calculate quantile of distributed dataset in MPI without transferring all data to root

Let say I have n processors. each produce a list of numbers. I would like to calculate the quantile of the merged list. Is there any way to do that without transferring all the sublist to the master. To fix idea for the mean it is very easy. IF (...
more »

2017-10-04 15:10 (0) Answers

## Sort Class List by specific Variable

I have a list of classes, which contains a string. The string I want to use to order the list by, looks like this: "A1534-11" I would like to order them by the 4 numbers after the letter. The basic OrderBy method just sorts it by the letter. How can...
more »

2017-10-04 14:10 (2) Answers

## Java 8 - Sort list of integers with nulls

Lets say you have a list of integers containing null vaues List<Integer> integers = Arrays.asList(null, 9, 11, 7, 5, null); Now if you want to get max value, you can try OptionalInt max = integers.stream() .mapToInt(Integer::valueO...
more »

2017-10-04 11:10 (3) Answers

## How to set the list by alphanumerical order?

I have a folder containing 10 subfolders with the following naming : Folder1,Folder2,Folder3,... i want to manipulate them by that order however when i apply lst = os.listdir(dirname) lst.sort() the output is the following : Folder1 Folder10 Fo...
more »

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

## How to sort a list of tuples that contain numpy array?

First, this is the code that does not work: ls = [(1.0,np.array([3.0, 4.0])), (1.0,np.array([3.0, 4.1])), (3.0,np.array([2.0, 1.0]))] ls.sort() As you can see, I have a list of tuples (ls). The first element of each tuple is a float number. I try ...
more »

2017-10-04 09:10 (2) Answers

## How to get column data of another table in laravel5?

First, I apologize for my poor English. I'm writing code to sort the page list. "link_for_sort" is a user function. function link_for_sort(\$column, \$text, \$params = []) { \$direction = request()->input('order'); \$reverse = (\$...
more »

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

## Returning the N largest values' indices in a multidimensional array (can find solutions for one dimension but not multi-dimension)

I have a numpy array X, and I'd like to return another array Y whose entries are the indices of the n largest values of X i.e. suppose I have: a =np.array[[1, 3, 5], [4, 5 ,6], [9, 1, 7]] then say, if I want the first 5 "maxs"'s indices-here 9, 7 ...
more »

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

## Firebase - How to retrieve data and sort it to display in list?

To give you some context: my project is a game and at the end of the game you can enter your Name and "submit" it to a leader-board. When submitting it's going to send your name and your global score to the Firebase. This far, I'm able to submit da...
more »

2017-10-03 21:10 (0) Answers

## Re-arrange HashMap keys in custom pre-defined order

I have an HashMap<String, String> that I need sorted in a specific order. I understand HashMaps, because of how they are constructed, cannot be easily sorted. However, I am looking for the best strategy to re-arrange the keys in my HashMap - fo...
more »

2017-10-03 16:10 (2) Answers

## foreach loop where order needs to be specific

I am trying to go through an array of shipping methods, and then set them in a table as an option. The problem is that my shipping methods are scrambled, and we don't want to rearrange it in our database. That means I need to go through all elements,...
more »

2017-10-03 15:10 (2) Answers

## PHP: order array with a user-defined comparison function and alphabetically by two values

it's my first post and I hope I do not make any mistakes. I have a choir memberlist as array: \$members = Array ( [0] => Array ( [0] => Bert [1] => T [1] => Array ( [0] => Claudia [1] => S...
more »

2017-10-03 14:10 (2) Answers

## Item date sorting from API JSON in angular

I've generated some news items from a laravel API output, i display these on a angular 4 cli project. I noticed the items aren't on descending order though and I'm trying to fix this on the client side. Check it out, this is what I've got. This is m...
more »

2017-10-03 11:10 (4) Answers

## How to sort a large array according to the alphabet specified in the array with a minimum loss of time?

How I can sort array with million values by letters specified in the array effectively with minimal waste of time. \$letters = array( "а","б", "в", "г", "ғ", "д", "е", "ё", "ҷ", "ж", "з", "и", "ӣ", "й", "к", "қ", "л", "м", "н", "о...
more »

2017-10-03 07:10 (2) Answers

## Custom comparator for achieving sort with multiple sort keys

There is an array of integers and there is a number M. The array needs to be sorted array with respect to the following criterion: (arr[i] % M, arr[i] / M) That is, the ordering is determined based on the result of arr[i] % M, and, in case of a ti...
more »

2017-10-03 06:10 (3) Answers

## Sort One Vector Based on the Elements of Another Vector With no Class or Struct

#include <algorithm> #include <fstream> #include <iostream> #include <vector> using namespace std; const int max_applications_num = 1000; vector<string> vector_authors; vector<string> vector_titles; vector<str...
more »

2017-10-03 02:10 (2) Answers

## Perl: find the max and min values in the array of hashes

I have the structure below in Perl: #!/usr/bin/perl use strict; use warnings; my %hash = ( 'firstitem' => { '1' => ["A","99"], '2' => ["B","88"], '3' => ["C","77"], }, 'seconditem' => { '3'...
more »

2017-10-03 01:10 (2) Answers

## How to sort LDAP Result with LDAP filter?

I'm creating a LDAP directory search using PHP. I'm able to successfully search and return results. I want to be able to sort results according to hierarchy. Now I have: ou=HR,ou=Employees,ou=People,dc=instatsport,dc=com ou=IT,ou=Employees,o...
more »

2017-10-02 20:10 (2) Answers

## How to get around strptime error, want to sort on a datetime string in a list of lists

I'm building a script to analyse performance data output from multiple log files. I managed to create a list of lists with all events and their timestamps, next step I need to sort this list of lists on the timestamp per event. So far so good I googl...
more »

2017-10-02 19:10 (0) Answers

## How to sort word frequency in a list (but not all of them printed) in Python

I have to count the word frequency in a list using python, but what I want is I want to count the words according to its occurance, but I dont't want to print it all For the example, i have this list lists = ["me","sleep","love","me","love","love",...
more »

2017-10-02 19:10 (2) Answers

## Java Collections - Print interstates sorted by population, city and state

I am working on a problem I came across in an interview. Input contains Population|City|State|Interstates list Output needs to be sorted in descending order by population first, then alphabetically by city and state, and then the interstates need ...
more »

2017-10-02 19:10 (2) Answers

## Extracting k largest elements

If I have n integers, is it possible to list the k largest elements out of the n values in O(k+logn) time? The closest I've gotten is constructing a max heap and extracting the maximum k times, which takes O(klogn) time. Also thinking about using ino...
more »

2017-10-02 18:10 (3) Answers

## Using Menu Buttons to modify LINQ search terms

In VBS 2015, I have created a form that uses a LINQ query to import a CSV file of names, locations, ages, ect., sorted using a unique record. The data is input into a Data Grid and then may be filtered and sorted by the selection of buttons from the ...
more »

2017-10-02 18:10 (1) Answers

## Storing XML with no Unique field.

i have a big xml file that i want to sort but i'm a little rusty on how to handle this case. I have a big xml file with about 40k rows but this xml file has no unique element that i can use to sort after. Is it possible to order by 2 elements so to...
more »

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

## Linewise lexicographic sort of a file with a catch

Although I am not happy with the title of this question and this might be an odd question; bear with me, please. So I have text files with content as follows: & AAABBAB this & AAAAAAB is & BCAAAA an & BBBBBA example & ...
more »

2017-10-02 13:10 (4) Answers

## JavaScript Sort by Date on table not working

Hi I cannot get sort function working on date. It changes order of the rows but it doesn't sort properly and dates are all over the place. I would like upcoming events to future events. See my code below. \$('tr.Entries').sort(function(a,b){ ...
more »

2017-10-02 07:10 (2) Answers

## Java: Find String with the highest value

I need to accept a string as input, split it into an array of individual words ( split on " ") and return the highest scoring word as a string. Each letter of a word scores points according to it's position in the alphabet: a = 1, b = 2, c = 3 etc. I...
more »

2017-10-02 05:10 (5) Answers

## PHP array sorting associative array using a specifc key value

I have an array which need to sort using a key value of "odbyx" Here is the array var_dump array(12) { ["id"]=> array(7) { [0]=> string(1) "8" [1]=> string(1) "7" [2]=> string(1) "3" [3]=> string(1...
more »

2017-10-01 18:10 (1) Answers

## Sorting by value higher to lower in array of objects

I have an array of objects that I need to sort by highest salary. I know I should use a user defined sorting function but not sure which one and how to do it. Here is my array: array(4) { [0]=> object(Employee)#1 (6) { ["name"]=> s...
more »

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

## 3-way Merge Sort C program

I have trying to "upgrade" my normal merge sort for a school project. But my new code seems to not coorporate as it should so i have a MergeSort3way function that splits the Array inputed in 3 subArrays then it call itself till the sort is finished ...
more »

2017-10-01 17:10 (2) Answers

## Heap sort is not used in C++ library

Since heap sort has time complexity of O(nlogn) in all scenarios i.e. best case,average case and worst case. While quick sort has time complexity of O(n2) in worst case. Then despite having less complexity in worst case, why heap sort is not impleme...
more »

2017-10-01 16:10 (2) Answers

## Having trouble with bubble sort Java

I'm try realize bubble sort and it's doesn't work! Help me find a problem. Code: public class Main { public static int e=0; public static int arraylength; public static int[] array = new int[10]; public static void main(String[] ...
more »

2017-10-01 15:10 (3) Answers