FAQ Database Discussion Community


Ordered set in Redis based on more than one criteria

redis,order,set,unix-timestamp
I am trying to create a redis ordered set. The catch is the ordering need to be done based on two criteria, timestamp and score. But in redis, I can only provide one soring criteria: ZADD {key} {timestamp} {value} How to add score in this ordering as well plz? Update:...

How to move rows and columns of certain indices to either end of matrix?

arrays,matlab,matrix,order
I have a matrix let it be A = 100x100 matrix and a vector B = [ 2 7 23 45 55 67 79 88 92] And I want to bring these rows and columns to the end of the array meaning the last 9x9 block in A to be...

comparing contents of a column to another data set

r,list,order
I am new to R and needed help to compare columns of content. I ordered my first table in terms of a particular column. For this I used the following function: x = fread ("x.txt", sep = ";") x_order = x [order (x $ V3)] I'm working with files that...

Unity3D ignoring my boolean variable

text,unity3d,order
I'm working on a project using Unity 4.6.1 and I'm experiencing a weird issue: I have a bool variable which is initially set to false, and I'm trying to set it to true in the Start() method. First of all, it happens that the function in the same script gets...

Order parent model using children in rails

ruby-on-rails,order,models
I have model product and vote, I need to order products by votes count DESC. product has_many :votes, vote belongs_to :product index_controller.rb def index @products = Product.all end ...

C# order of values calculated in parallel in LINQ

c#,linq,order
I am trying to create a specific Image[] created from byte[]. Here is the code in LINQ: return thumbnails.AsParallel() .Select(t => FromByteArray(t)) .ToArray() Here is the code of the used method: public static Image FromByteArray(byte[] arr) { using (MemoryStream ms = new MemoryStream(arr)) return new Bitmap(ms); } Will it always...

Prestashop 1.6 : Display a line TotalProductsTaxes in order-detail.tpl

order,prestashop,prestashop-1.6
I want to display a Total Taxes line in the Order-Detail.tpl I added that line of code but I don't know what to write to get TotalProductsTaxes instead of TotalProductsWithoutTaxes. I tried several things but they all broke the page. <tr class="item"> <td colspan="{if $return_allowed}2{else}1{/if}"> <strong>{l s='TVA :'}</strong> </td> <td...

Can not order by when using UNION in mysql

php,mysql,sql,order,union
I have this query that is working if I do no do UNION: SELECT t1.offer_id, t1.cpv_id, t1.type, FROM `offer_cpv` t1 JOIN `offer` t2 ON t1.offer_id = t2.id JOIN `company` t3 ON t2.cmpid = t3.id WHERE t1.cpv_id = :cpvid AND t3.status IN (4, 6) GROUP BY t1.offer_id ORDER BY t1.type Key...

Why does ordering by factor destroy the decimal places

r,ggplot2,order
I am try to do a simple ggplot of my dataframe structure(list(CLevel = c(3, 4, 5, 6, 7, 8, 9, 10, 11), Sensitivity = structure(c(1L, 2L, 3L, 3L, 5L, 5L, 7L, 8L, 9L), .Label = c("56.6666666666667","53.125", "52.9411764705882", "52.9411764705882", "54.2857142857143", "54.2857142857143", "55.5555555555556", "56.7567567567568", "57.1428571428571"), class = "factor"), Specificity = c(76.4705882352941, 76.4705882352941,...

Way to get the value of an empifical cdf

r,order,cdf
All, I have an array as follows: x=runif(1) cdf=cumsum(c(.2,.5,.1,.05,.05,.01,.09)) >p [1] 0.20 0.70 0.80 0.85 0.90 0.91 1.00 How do I return the index of the corresponding cdf entry for x? for example, .1 would return 1, .98 would return 7)...

R order a table for barplot by predefined settings

r,graph,order,bar-chart
I have a table that looks like this: cos_table<-table(df$COS) #simply count the frequency of COS in the table A B C D 2880 6001 834 2833 When I plot it with barplot(cos_table) I get a bar plot with the order of A B C D My request is to organize...

Split a data frame and sort the splitted values based on a particular column

r,order,data.frame
I have a following data frame tdf <- structure(list(GO = c("Cytokine-cytokine receptor interaction", "Cytokine-cytokine receptor interaction|Endocytosis", "I-kappaB kinase/NF-kappaB signaling", "NF-kappa B signaling pathway", "NF-kappaB import into nucleus", "T cell chemotaxis"), PosCount = c(17, 18, 4, 5, 1, 2), shortgo = structure(c(7L, 7L, 18L, 18L, 18L, 21L), .Label = c("TNF", "adaptive",...

Elasticsearch PUT documents in strange order

c#,.net,browser,elasticsearch,order
How do set elasticsearch to be adding new documents with PUT method at the end (or the beginning). Now it's adding new ones sometimes at the end, sometimes in the middle. I know I can sort results by some field, but I want to see them in browser just ordered...

Reorder digits in integer using C#

c#,sorting,numbers,order,int32
I want to ask how I can reorder the digits in an Int32 so they result in the biggest possible number. Here is an example which visualizes what I am trying to do: 2927466 -> 9766422 12492771 -> 97742211 I want to perform the ordering of the digits without using...

How to order by a boolean field in Odoo?

order,openerp,odoo,odoo-8,kanban
I can't understand the behaviour of the Odoo API. It's driving me crazy. As you may know, if you want to order a model by some of its fields, you have to modify the attribute _order of the model. It works fine. Now, suppose you want to order a specific...

MySQL group_concat() month wise ordering

mysql,order,group-concat
I have a mysql table with date column named MonthYear which contains dates from March 2013 to Jan 2014 in yyyy-mm-dd format. I trying to group_concat() the that column as, select GROUP_CONCAT(DISTINCT CONCAT(' ROUND(SUM(CASE WHEN DATE_FORMAT(MonthYear, ''%b %y'')=''', DATE_FORMAT(ms.MonthYear, '%b %y'), ''' THEN Count ELSE 0 END)) AS ''', DATE_FORMAT(ms.MonthYear,...

How to verify the sorting(ascending and descending) functionality in casperjs

javascript,testing,order,casperjs,columnsorting
I am new to this framework and also not getting any idea how to test the sorting functionality with CasperJS. The scenario is, I need to verify the search results with sorting functionality. When i search with any keyword it displays all the possible matching results. ...

SQL SELECT ORDER BY multiple columns depending on value of other column

mysql,sql,order
I have a table with the following columns: id | revisit (bool) | FL (decimal) | FR (decimal) | RL (decimal) | RR (decimal) | date I need to write a SELECT statement that will ORDER BY on multiple columns, depending on the value of the 'revisit' field. ORDER BY...

Keep input order in nested dictionaries

python,dictionary,order,nested
How can I preserve the input order of nested dictionaries? Specifically: I use another dictionary to make it the nested dictionary of an ordered dict (named 'outdict'), and then I add new keys. Example data: example1 = {'x': '28', 'y': 9,'z': '1999'} example2 = {'x': '12', 'y': 15,'z': '2000'} test1...

Execution order in Java

java,loops,order
Here is a part of my code: Thread refreshHistory=new Thread(()->{ try{ while(true){ todoDA.refreshHistory(); Thread.sleep(secondsToWait*1000); } }catch(Exception e){} }); Is there a way to make sure that todoDA.refreshHistory(); will be always executed before thread goes to sleep? I was having Abort due to constraint violation (NOT NULL constraint failed: Tag_todo.todo_id). At...

Giving a row number to mysql data based on date

c#,mysql,winforms,order,row-number
I have been trying to add a row number for my data i.e. each row would have a number based on my ordering, if I list them based on date, the one which is the oldest date would get row number 1 and so on regardless of their actual id...

ORDER BY UPPER(column) is wrong in MySQL

mysql,sql,order,sql-order-by,mysql-5.6
With MySQL 5.6, given the following table structure: mysql> describe groups; +-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(500) | YES | | NULL | |...

MySql - Sort persons by name and partner

php,mysql,sorting,order,grouping
I'm dealing with the following problem in a MySQL/PHP web application: A table of persons looking having the columns: ID, firstname, surname, idOfPartner, street, zipCode should be ordered by the surname of the person which should be then followed by the partner of the person so the result would look...

Issue with Order By with FOR XML in T-sql (The ORDER BY clause is invalid in views, inline functions, derived tables)

sql,sql-server,xml,order
select a.Hall, a.Title, STUFF((SELECT ', ' + '[' + CONVERT(varchar(2),DATEPART(Hour, b.StartFilm)) + ':' + CONVERT(varchar(2),DATEPART(Minute, b.StartFilm)) + ' ' + CONVERT(varchar(2),DATEPART(Hour, b.EndTime)) + ':' + CONVERT(varchar(2),DATEPART(Minute, b.EndTime)) + ']' FROM (select c.Name as Hall, b.Title, Convert(time,a.StartFilmTime) as StartFilm, Convert(time,a.EndFilmTime) as EndTime from FilmSchedule a left join Film b on a.FilmId...

Scala - sort tuples by first element reverse, second element regular

scala,sorting,order
I have tuples of the form (Boolean, Int, String). I want to define Ordering which sorts the tuples in the following order: Boolean - reverse order Int - reverse order String - regular order Example: For the tuples: Array((false, 8, "zz"), (false,3, "bb"), (true, 5, "cc"),(false, 3,"dd")) The ordering should...

Ordering content with in columns in Bootstrap Grid

css,twitter-bootstrap-3,order
I have a simple bootstrap grid set for two columns ( content left and right ) that break down everything to one column in mobile and tablet. <div class="row"> <div class="col-md-6">Left Column</div> <div class="col-md-6">Right Column</div> </div> The problem is I'm trying to order stuff INSIDE each column after both columns...

How to generate an optimal order of multiple elements based on pairwise element score values

python,optimization,order,mathematical-optimization
I have a number of elements, let say [a, b, c, d], and for each pairwise combination I have a score: [['d-a', 0], ['a-b', 0], ['b-a', 0], ['a-c', 2], ['c-a', 0], ['a-d', 2], ['d-b', 1], ['b-c', 2], ['c-b', 0], ['b-d', 2], ['d-c', 2], ['c-d', 2]] I am looking for a...

Lua in pairs with same order as it's written

loops,lua,order,lua-table
Is there any way to loop trough a table like the one below in the same order as it's written? local tbl = { ["hello"] = 1, [2] = 2, [50] = 3, ["bye"] = 4, [200] = 5 } What I mean is that when I use "in pairs"...

TreeSet not Re-Ordering Itself after Values in it are Changed

java,data-structures,order,comparator
I have a TreeSet in JAVA which orders a custom datatype called 'Node'. However, the TreeSet does not order itself properly. A link to my complete implementation is at the bottom. Let me explain my probelm in detail first Here have a custome datatype 'Node'. It has 2 parameters as...

Is this a known ordering algorithm?

algorithm,sorting,order
I was doing some practicing and implemented some well known order algorithms, and I thought that if we look at the list sideways it should appear sorted without doing any work (See code, it's pretty self explanatory). Pretty sure it's already thought of/done and I would like to know what...

R - Assign value to multiple cell based on a combination of values

r,order
I have the following data.frame, where the multiple X columns (1,2,3... N) are blank: df1 <- data.frame( name = c("A","B","C"), X1 = c("","", ""), Y1 = c("aa","bb","cc"), Z1 = c("AA","BB","CC"), X2 = c("","", ""), Y2 = c("dd","",""), Z2 = c("AA","",""), X3 = c("","", ""), Y3 = c("","","ee"), Z3 = c("","","CC"))...

loop logic can't effect every element

php,loops,order,logic
thanks in advance for helping, and looking. I have a bunch of images whose paths and metadata I need to process in a web directory: e.g. 'path/to/files/u_1.jpg' $list=array_values($list); foreach ($list as &$value) list($width, $height) = getimagesize($dir.$udir.$value); $value = $predir.$udir.$value.$wid.$width.$hgt.$height.$lft.$end; I used scandir to get the elements into the $list array...

How to make the error bars move with the barplot when re-ordering factors?

r,plot,ggplot2,order
I am plotting a barplot with error bars. And here's what I got so far. The problem is that the error bars do not appear in the place where they should be. If I don't force the ID levels, by removing the df2ID <- factor(df2$ID, level = c('Gary','Jack', 'Alice')) line,...

django 1.7 order by related field error

python,django,order,django-queryset
I'm fairly new to Django. I've a problem ordering queryset by a related model field. I've already seen the similar questions on stackoverflow but I'm stuck with this silly error, I would like have all the records from "MktIn" ordered by "nome" field from "Squadre" model The relation is one...

PHP/MySQL: Order table by default

php,mysql,table,order
I am currently working on an event calendar which allows users to sort between date & place and date & place. This is the code I use for the order: $order = isset($_GET['sort'])?$_GET['sort']:'date_added'; $result = mysqli_query($con,"SELECT * FROM calendar ORDER BY $order"); $sql = mysql_query($query); Now when you click on...

Mathematica Order of an Equation

order,wolfram-mathematica,equation
Is there a way to obtain the order of an ODE in mathematica. For example, if i have y''+5y i want mathematica return 2 (beacuse it's a 2nd order equation). So, is it possible what i'm asking? ...

Python - How to Order a multidimensional Array using another array

python,multidimensional-array,order
Quick Summary: need_to_reorder = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]] I want to set an order for the need_to_reorder[0][x] x values using my sorting array sorting_array = [1, 3, 0, 2] Required result: need_to_reorder will equal [['b', 'd', 'a', 'c'], [2, 4, 1, 3]] Searching for the answer,...

Change order of words Java

java,string,order
I cannot figure out how to change the order of a given name. For example: Van-Dame Claud Result: Claud Dame-Van I created this method, but it seems that is not correct, any suggestion or maybe a better method? public String NameInvers(){ String Name, Name = null, Name = null, NameFinal;...

how to add the order by Sum function in a query?

sql-server,order
i just have this query and I want to add the ordering of its records by the result of the sum function, how to add this? Select bus.trans_comp_id, SUM(bus.passengers*trips.cost) From bus inner join trips on bus.ID=trips.bus_id group by bus.trans_comp_id out put of this: trans_comp_id 1) 1:412000.00 2) 2:75000.00 I want...

Ancestry: sorting on number of children

ruby-on-rails,ruby,sorting,order,ancestry
I want to sort my parent object on basis of number of children it has. Ancestory has this method 'child_ids' which return all the children ids. Is there a way I can use that to sort my parent objects? Project.order(child_ids.count) or Project.order(Project.child_ids.count) don't work. I guess that is obvious. Any...

Extract an increasing subsequence

r,order,subsequence
I wish to extract an increasing subsequence of a vector, starting from the first element. For example, from this vector: a = c(2, 5, 4, 0, 1, 6, 8, 7) ...I'd like to return: res = c(2, 5, 6, 8). I thought I could use a loop, but I want...

Sqlite order by, AaBbCc

sqlite,sqlite3,order
I have been trying to get sqlite to order a set of entries by name in the following order AaBbCcDd......Zz but the closest I've gotten is using COLLATE NOCASE to get a case insensitive sort. The entries I have are Addy|2000-01-22T16:06:14.155Z alice|2000-01-22T16:06:20.514Z billyRay|2000-01-22T16:06:36.175Z Bobby|2000-01-22T16:06:26.868Z claus|2000-01-22T16:06:52.531Z CoffinLLC|2000-01-22T15:33:11.235Z Default|2000-01-22T15:55:12.168Z I have tried...

Firebase: combine filtering with ordering in swift

swift,filter,order,firebase
So I have a sports app, which handle matches and championships data. I have two displays using the same data: All future matches All future matches from a certain championship The data is structured like this - championships - libertadores - name: Libertadores da América - matches - 2j6g42kjhg62 -...

delete contents of nth file in a folder batch

batch-file,file-io,order
I have a program that does things with video files depending on the file order, so for example it calls on the 45th or 10th file in a folder, but never the same one twice. Now, to save SSD space I want to delete only the contents of that nth...

reset row_number for different groups in SELECT

sql,sql-server,order,rowcount
I need to add different groups of row counts to my selected data like below: no. date co. 1 15/5/7 a 2 15/5/8 a 3 15/5/9 a 1 15/5/7 b 2 15/5/8 b 3 15/5/9 b my current code is like this : select row_number() over(order by date) as no,date,...

How to edit and update the Item Status of an Order Item in an order in magento

magento,order
As soon an order is placed in magento, the order item has Item Status as 'Ordered'. I am able to fetch this status. But I need to edit this status,something like 'creating'. Tried Using the code below but the changes are not reflected $order = Mage::getModel("sales/order")->loadByIncrementId($orderId); $ordered_items = $order->getAllVisibleItems(); foreach($ordered_items...

Manipulate Object literal: add property in certain order

javascript,json,object,properties,order
I'm developing a tool to create Nassi-Shneiderman diagrams online. The model for each diagram is simply an object literal, storing everything with unlimited possible children. this then results in a view populated like the following: Now if I want to add let's say a sequence into the while loop after...

Sorting files in numerical order in Go

file,sorting,for-loop,go,order
I am reading a directory, and with this I've noticed that if I have files which are ordered by number (1, 2, 3, 4...) then it seems to use some alphabetic ordering. Say that I have 13 files (named 1.md, 2.md, 3.md...), the ordering would look like: 1, 10, 11,...

Order on basis of multiple columns

sql,ruby-on-rails,ruby,order
Suppose I have table project which has following fields: number of issue number of comments number of followers created_at I want to sort project on basis of all the fields, however each field has different precedence. A project with higher issue should be higher up even if it has lesser...

Split Data and order columns

r,order,sapply
I am trying some split-apply-combine methods. How do I split a data into different categories and then sort each categories on descending order of a particular column. First I split mtcars spmtcars <-split(mtcars, mtcars$cyl) then if I do sort_mtc <- spmtcars[order(mpg), ] Error in order(mpg) : object 'mpg' not found...

T-SQL Ordering a Recursive Query - Parent/Child Structure

sql,tsql,recursion,order,hierarchy
I am trying (and failing) to correctly order my recursive CTE. My table consists of a parent-child structure where one task can relate to another on a variety of different levels. For example I could create a task (this is the parent), then create a sub-task from this and then...

Ordering panel data in ggplot2 by the value of the observation in one certain year

r,plot,ggplot2,order
I am plotting a simple panel of data with ggplot2. Observations from the same individual (region) are from two different waves, and I want to plot my graph ordering individuals by the value of only one of the waves. However, ggplot by default orders by the mean value of both...

SQL select and group records with same words in different order

sql,regex,postgresql,group-by,order
I have the following values in a table: Table Fruits id | name | price ----------------------------------------- 1 | 'APPLE BANANA ORANGE' | 12.00 2 | 'BANANA ORANGE APPLE' | 4.00 3 | 'ORANGE APPLE BANANA' | 10.00 4 | 'LEMON APPLE BANANA ORANGE' | 7.00 5 | 'APPLE LEMON BANANA...

OrderBy gets ignored

angularjs,date,order,angularjs-ng-repeat
I have the following ng-repeat: <div ng-repeat="location in truckDetail.locations track by $index | orderBy:location.startDate" class="locationLoopRow"> <span class="rowEdit"><i ng-click="location.editMode=!location.editMode" class="fa {{location.editMode?'fa-ban':'fa-pencil'}}"></i></span> <span class="rowDate">{{location.startDate|date:'dd.MM.yyyy'}}</span> <span class="rowDate">{{location.endDate|date:'dd.MM.yyyy'}}</span> <span...

How can I get the top N records of a MySQL table by excluding an array of groups?

php,mysql,performance,order,records
Here's a table example: Table: websites Domain | Category | Popularity google.com | 0 | 13,430 yahoo.com | 0 | 1,094 facebook.com | 1 | 23,943 youtube.com | 2 | 17,320 imdb.com | 3 | 6,094 stackoverflow.com | 4 | 2,930 ebay.com | 5 | 5,748 yandex.com | 5 |...

How to get asccending order item by date?

ios,objective-c,date,order
I have one dictionary with many items. I want order ascending items by date. My date format is: 10-Jun-2015 09:27:11 I tried this code but didn't work: aux is my array with dates components. for (int i=0; i<aux.count-1; i++) { for (int j=i+1; j<aux.count; j++) { NSDateFormatter *dateFormat = [[NSDateFormatter...

Order By count(*) from other table in yii 2

php,mysql,activerecord,order,yii2
I have 2 table: videos and likes video table has fields: id, title .. likes table has fields: id, video_id, user_id I would like to get the 10 most like videos. I can do it in sql by command: SELECT videos.*, COUNT( likes.video_id ) AS countlike FROM videos LEFT JOIN...

Python, simple string ordering by datetime

python,datetime,order
I've got the number of records (as strings) and those strings: 5 01.06.2012 09:45 a a a 01.06.2012 08:00 b b b 21.12.2012 21:00 c c c 13.07.2011 17:00 d d d 26.05.2012 08:00 e e e I want to order them by date and print ordered. I know I...

ServiceStack AutoQuery ordering

order,servicestack
I am using AutoQuery which makes writing services very simple. One of my queries needs to order descending by value X and then ascending by value Y. It appears that in AutoQuery you can order everything ascending or descending but not a combination. To get around this I added custom...

Why does failing to recognise equality mess up C# List sort?

c#,order
This is a somewhat obscure question, but after wasting an hour tracking down the bug, I though it worth asking... I wrote a custom ordering for a struct, and made one mistake: My struct has a special state, let us call this "min". If the struct is in the min...

How to order a list of points by distance to a given point?

python,order
I have a list of items that have X and Y coordinates. Now, there's a method that takes X and Y parameters and should return a the list of coordinates ordered from the closest to the farthest based on the given parameters. Basically, it looks something like this: class Point:...

Numerically listing Arrays

java,arrays,order,numerical
So my code is having a problem. Here's what I want to do: have one array have the original set of numbers (up to 10 numbers) and then copy and paste those numbers onto the second array. And then afterwards, the second area lists those numbers from the first array...

How do I order a list and add position to its items on MongoDB?

mongodb,list,sorting,order
I'm creating a Leaderboard system using MongoDB, so, I would like to know if its possible for me to get the position of a document in a list and its neighbords. { "_id": null, "name": "user_341c88077d", "value": 140 }, { "_id": null, "name": "user_6fd772cb84", "value": 160 }, { "_id": null,...

How to order Data from a row properly

php,mysql,order,row
How can i order results from a mysql row. Currently my code is as such: require 'dbconnect.php'; // Query the database $resultSet = $conn->query("SELECT * FROM wp_wppizza_orders"); if($resultSet->num_rows != 0){ // Turn the results into an Array while($rows = $resultSet->fetch_assoc()) { $id = $rows['id']; $klantgegevens = $rows['customer_details']; $bestelling = $rows['order_details'];...

reset object order javascript

javascript,object,order,reset
I have a object like this { "items":{ "2":{ "id":122, "product_id":"DE", "price":"9.35", }, "4":{ "id":15, "product_id":"CH", "price":"8.00", } "7":{ "id":78, "product_id":"CH", "price":"3.00", } }, "total_price":"20.35", "item_count":2, "unit":"CHF" } Do you know how i reset the items order. now 2, 4, 7 should be 0, 1, 2...

SQL - How to randomly choose an ordered subset?

python,mysql,sql,random,order
I have a table which roughly looks like so: id | unique | group ---------------------------------- 1 | aaa | group1 2 | bbb | group1 3 | ggg | group1 4 | iii | group2 5 | ooo | group2 6 | eee | group3 7 | ttt | group4...

Android Button orders to front automatically

android,button,layout,order,bringtofront
something weird is happening to me. I have this layout: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/gray_dark" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true"...

Order posts by number manually entered by the user

algorithm,sorting,design,order
I have a website which its admin user logs into a restricted area and adds content that is displayed on the public area. The admin wants a simple input text field on the post insert/edit form where he can type a number that determines in which position that post will...

How to find a list of steps needed to reorder a list to get another list?

arrays,algorithm,list,order,reorderlist
Let's assume we have to lists (Expressed as arrays or whatever in any language). These lists are equally long and contain the same unique elements - but in a different order. For example: First list: A, B, C, D Second list: A, D, B, C Now what I'm trying to...

How to .limit order by DESC, then order by (:id)?

ruby-on-rails,ruby,tags,order,tag-cloud
This limits the tags to the top 20 with the highest tag count: tag.rb scope :top_20, -> { where("taggings_count != 0").order("taggings_count DESC").limit(3) } I want to then order those 20 according to their :id instead of by their tagging_count application_controller before_action :tag_cloud def tag_cloud @tags = Tag.all.top_20.order(:id) end .order(:id) unfortunately...

How to reset the ordering of columns with bootstrap 3 at extrasmall screens with preserving showed html markup?

html,css,twitter-bootstrap-3,order,multiple-columns
Here is the html code what is: <div class="col-sm-9 col-sm-push-3">Content</div> <aside class="col-sm-3 col-sm-pull-9">Some aside text</aside> At extrasmall screens main content goes first before the aside section. But how to make it go first and the aside element second preserving initial html markup and only at an extrasmall screens? and all...

Group By Date and SUM int - Date formatting and Order

sql-server,date,casting,order,group
I'm trying to get the SUM of the quantity sold on a day. I need the results to be in ORDER BY date. The query below gives me the exact result I need, except the date is not formatted to what I need. SELECT CAST(Datetime AS DATE) AS 'date', SUM(quantity)...

elastic search sort in aggs by column

sorting,elasticsearch,group-by,order
I am trying to sort in elastic search in aggs, equivalent in mysql "ORDER BY Title ASC/DESC". Here is the index structure: 'body' => array( 'mappings' => array( 'test_type' => array( '_source' => array( 'enabled' => true ), 'properties' => array( 'ProductId' => array( 'type' => 'integer', 'index' => 'not_analyzed'...

Rails 4 - order by related models created_at - activity

mysql,ruby-on-rails,ruby-on-rails-4,order,rails-activerecord
In my rails app I have few related models for example: Event has_many :comments has_many :attendents has_many :requests What I need is to order by 'created_at' but not only main model (Event) but also related models, so I will display on top of the list event with most recent activity...

How to iterate through a table in its exact order?

loops,for-loop,lua,order
If i try to output this table, they are looped through in the false order: local letters = {DIN1="hi", AIN1= "my", AIN2 ="name", DIN2="is"} for name, value in pairs(letters) do print(name,value) end Expected Output: DIN1 hi AIN1 my AIN2 name DIN2 is Output: AIN1 my DIN2 is DIN1 hi AIN2...

How to order SQL query result on condition?

sql,postgresql,order,condition
i have the this SQL query: SELECT DISTINCT category FROM merchant ORDER BY category ASC that gives this output: accommodation education food general health money shopping sport transport How to put the row that contains "general" at the start (or the end) of the result?...

Clearing empty positions and ordering dc.js bar chart

order,dc.js,crossfilter
I've used a fake group to fix my issue with plotting only top(n) values on a graph. Now I found an other issue that the bar chart shows a few empty positions for those data fields that doesn't come under 'ton(n)', I want to remove them and sort the bars...

calculate distance live and order asc|desc

sql,order,distance,live
So when i start the web app, the server gets the user geolocation and save it as variable (latitude/longitude) I've got a database with: ID, Name, Latitude, Longitude Now i want to select all entries from the database and order them by distance I know how to calculate the distance...

Unpredictable file order in gulp

javascript,order,gulp
I have the following task: var inject = require('gulp-inject'); ... gulp.task('index-build', function () { return gulp.src(config.index) .pipe( inject(gulp.src(config.build + '/vendor/**/*.js', { read: false })) ) .pipe(gulp.dest(config.build)); }); Mostly this does what it's supposed to: concatenate files in alphabetic order within the paths, resulting in something like: ... <script src="/vendor/angular/angular.js"></script> <script...

php matching array names to another array's values

php,arrays,order,match
I have some data that is available to me in arrays. I have to display the data in rows and columns, like a table. The first array, $header, looks like this: $header[0]=a, $header[1]=d, $header[2]=b, $header[3]=c, $header[4]=e This array can have any number of elements. The subsequent arrays represent the rows...

Find intersection of polygon and order by line

c#,order,geometry,polygon,intersection
I was wondering if there is a method to order intersection points in a list based on the direction of the intersected line. Here is a picture to get the idea: The red numbers are the polygon lines which exist in a List. Then I have another List with lines...

How can I efficiently order eager loaded records?

sql,ruby-on-rails,ruby,postgresql,order
I have a model Playlist, and a model User, both of which have_many of each other, through a join model PlaylistUser. On my playlists#show action, I want to print a list of all of a Playlist's Users, along with the first two Playlists (ordered by :song_count) associated with each of...

Algorithm to determine an order of processing/sorting

algorithm,sorting,language-agnostic,order,priority
I've got an application that has to return 100s of user-creatable documents in a user-configurable, deterministic and consistent order. What is the best way to acheive this? I was hoping to use an enum (eg High, Medium and Low priority) as this keeps things simple and closed, but the ordering...

Check if elements clicked in a specific order

javascript,jquery,validation,click,order
I am beginner on JavaScript and I need to do a test for children. I have 3 square and I need to check and display if this was clicked in a specific order, defined by "order" property. The validation of click is displayed on corresponding span element status-1 for click...

Sorting out a vector by smallest number first, doing the exact same opposite?

c#,order
I've been trying to make this vector/object sorter all day and even if I exchange the signs (< and >) nothing seems to be happening. I have integers randomly put in a random order and the objective for the program is to sort them by size. I have sketched it...

How to give same rank to rows with same data in some columns then increase when data changed SQL

sql-server-2008,order,dense-rank
I am trying to use Dense_Rank in my SQL Query to rank rows with same data in some columns, and then increase it when changed data is found in next row. I was successful in doing so by this query: SELECT DENSE_RANK () OVER (ORDER BY ID, Date1) AS P_Key,...

Sort pairs of columns in a dataframe, based on another customly ordered column

r,sorting,order,data.frame
I have searched through web but I could not find a solution to my problem. I have a data like below df <- structure(list(V1 = c("ATP1A2", "CAPRIN1", "ATP1A1", "CBX3", "AUP1", "LARS2", "MTHFD1", "VDAC2", "PRKCSH", "ATP1B1", "B3GNT3", "", ""), V2 = c("ATP1A1", "ATP1A2", "ATP1B1", "AUP1", "B3GNT3", "CAPRIN1", "CAPRIN1", "CBX3", "", "",...

Conditional Order of Operations in C#

c#,python,order,conditional
So I was recently going through the tutorial for Python on CodeAcademy and I came across this part. Where it instructs that Python has a set order in which it evaluates conditionals. I had never heard of anything like this before. I'm used to coding in C# and was wondering...

Howto select (almost) unique values in a specific order

sql,order,distinct
In a trip there are several stops, (a stop = an adress whereone or multiple orders are loaded, or delivered), in a specific order. For example: Trip A Trip_order Action Place Ordernumber 10 Load Paris 394798 20 Load Milan 657748 30 UnLoad Athens 657748 40 Unload Thessaloniki 394798 50 Load...

Get Order Details by Order Id

magento,search,order,magento-1.9
I need to retrieve an order from Magento by its id. How do I load a specific order by id?

Hex change low to high and then conever to decimal

c#,order,hex,decimal
I have Hex string like 1480D604. Which I need to change order from Low to High 0x04D68014 and then I need to cast it into decimal value. One approach that I can think is first change their order first like. Step 1 : 14-80-D6-04 --> 04-D6-80-14 How can I change...

Can data ord be replaced with only RealFloat in comparing numbers in Haskell?

haskell,floating-point,functional-programming,order
maxs :: (RealFloat a) => a -> a -> a maxs a b | a>b = a | otherwise = b maxs :: (Ord a) => a -> a -> a maxs a b | a>b = a | otherwise = b I'm trying to write a max function using...

R, ggplot2, facetted histogram, decending order, factor x-axis labels

r,ggplot2,order,facet
I have an interesting problem where I need to produce a facetted histogram series which I want to put in decending order for each panel. This below code replicates the problem. library(ggplot2) set.seed(1) nGroup = 10; nSample = 10 df <- data.frame(Group=rep(1:nSample,nGroup), Category = factor(sample(LETTERS, nGroup*nSample, replace=TRUE), levels=LETTERS), Amount =...

ordering non-decreasing functions then adding them in R

r,function,order,sequence,rstudio
Need help with basic R function: Firstly order non-decreasing sequence from 4 different sequences and then order those 4 sequences into one. Im totally green in programing so please make it the simplest way possible. Edit1: puting some input data as required A={3,2,1,2} B={6,7,5,8} C={12,11,9,10} D={65,43,76,13} I would like it...

Why my HashMap puts an element in position 6 instead of the next empty position?

java,hashmap,order
I'm running the following code in a method, but at the time of return the key and value <"dataInicio">,<"orange"> are at position six of the map instead of position one like it should've. What could be doing this? I'm creating this map to sends as parameter to a Jasper report...

Evaluation order

order,evaluation
I have a question about programing in general, Could someone explain me why : Evaluation of parameters from right to left is more efficient than left to right Unspecified evaluation is more optimized than the other 2 Thanks, Nathan...

Search by Mutual Friends Count - Friend System Mysql PHP

php,mysql,sql,select,order
I am creating a Friend System in my Forum. I am having a tough time trying to figure out how I would grab users and order by the mutual_friend count. I am trying to build a page that shows a list of recommended friends. Here is my structure of tables:...

Circular Path algorithm

algorithm,order,path-finding,circular-dependency
I am stuck at developing a circular path algorithm creating a path out of points. This is the array I am starting with: (1,1) (1,6) (2,2) (2,5) (4,1) (4,2) (6,5) (6,6) These are points in a coordinate system and I want to be ordered so I only need horizontal or...

Order results by time added, but rank them by vote count

php,mysql,order,ranking
I'm writing a web app where people can add and vote on ideas. When outputting the ideas I want them to be ordered by their total vote count or time added, but always have a rank based on the vote count. This is what I have now: function get_ideas($status, $sortby,...

Merge two linked lists Order

list,merge,order
I have two sorted linked lists and need to merge them. l1 = [a] -> [b] -> [c] l2 = [b] -> [f] l1plus2 = [a] -> [b] -> [c] -> [f] What order would this be?...