natural-sort

R: mixedsort on multiple vectors (columns)

旧巷老猫 提交于 2019-12-11 19:16:07
问题 This is a follow-up on this question, which was marked as a duplicate to this, but the suggested solution does not work. I have the following data.frame : set.seed(1) mydf <- data.frame(A=paste(sample(LETTERS, 4), sample(1:20, 20), sep=""), B=paste(sample(1:20, 20), sample(LETTERS, 4), sep=""), C=sample(LETTERS, 20), D=sample(1:100, 20), value=rnorm(20)) > mydf A B C D value 1 G5 6N T 9 -0.68875569 2 J18 8T R 87 -0.70749516 3 N19 1A L 34 0.36458196 4 U12 7K Z 82 0.76853292 5 G11 14N J 98 -0

How to Implement 'NaturalSort' in jqGrid

别等时光非礼了梦想. 提交于 2019-12-11 10:08:32
问题 I started my search to implement 'NaturalSort' in jqGrid, I have Javascript code for NaturalSort as below: this.naturalSort = function (a, b) { var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi, sre = /(^[ ]*|[ ]*$)/g, dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, hre = /^0x[0-9a-f]+$/i, ore = /^0/, i = function (s) { return naturalSort.insensitive && ('' + s).toLowerCase() || '' + s }, // convert

Natural sort supporting big numbers

人走茶凉 提交于 2019-12-11 02:25:29
问题 I have some data like this: id | templateName ----+-------------- 10 | a 61 | a 63 | a 4 | a 6 | a 7 | a 34 | a 35 | a 62 | a 1 | a 13 | a 25 | a 26 | a 66 | a 68 | a 70 | a 65 | a 5 | a1 73 | a5 3 | a15 2 | a15a 69 | a15b 64 | a15b4 74 | a15b21 8 | a214748364 I'm doing natural sort with the following code: CREATE TYPE ai AS (a text, i int); select id, "templateName" from daily_templates order by ARRAY(SELECT ROW(x[1], CASE x[2] WHEN '' THEN '0' ELSE x[2] END)::ai FROM regexp_matches(

Numeric order when returning results from MySQL

↘锁芯ラ 提交于 2019-12-10 23:34:52
问题 I have the following types of titles in a table in my db: Topic 1 blah blah Topic 2 blah blah Topic 3 blah blah ... Topic 10 blah blah Topic 11 blah blah etc... The select query will always return the results like this: Topic 1 blah Topic 10 blah blah Topic 11 blah ...leaving out Topic 2, Topic 3 etc... until after all the teens will I get Topic 2 etc... How can I get my results as: Topic 1 Topic 2 Topic 3 .... all the way to Topic 9 and only then have Topic 10? 回答1: This is a problem with

How to implement a natural sort algorithm in c++?

空扰寡人 提交于 2019-12-10 14:54:32
问题 I'm sorting strings that are comprised of text and numbers. I want the sort to sort the number parts as numbers, not alphanumeric. For example I want: abc1def, ..., abc9def, abc10def instead of: abc10def, abc1def, ..., abc9def Does anyone know an algorithm for this (in particular in c++) Thanks 回答1: I asked this exact question (although in Java) and got pointed to http://www.davekoelle.com/alphanum.html which has an algorithm and implementations of it in many languages. 回答2: Several natural

C#: Implementation of, or alternative to, StrCmpLogicalW in shlwapi.dll

可紊 提交于 2019-12-08 14:40:27
问题 For natural sorting in my application I currently P/Invoke a function called StrCmpLogicalW in shlwapi.dll. I was thinking about trying to run my application under Mono, but then of course I can't have this P/Invoke stuff (as far as I know anyways). Is it possible to see the implementation of that method somewhere, or is there a good, clean and efficient C# snippet which does the same thing? My code currently looks like this: [SuppressUnmanagedCodeSecurity] internal static class

How to order list of strings on number substring using C#

与世无争的帅哥 提交于 2019-12-08 09:29:00
问题 I have a list of strings, each containing a number substring, that I'd like to be reordered based on the numerical value of that substring. The set will look something like this, but much larger: List<string> strings= new List<string> { "some-name-(1).jpg", "some-name-(5).jpg", "some-name-(5.1).jpg", "some-name-(6).jpg", "some-name-(12).jpg" }; The number will always be surrounded by parentheses, which are the only parentheses in the string, so using String.IndexOf is reliable. Notice that

How to achieve Natural(human alpha-numeric ) Sorting, for silverlight datagrids using ViewModel?

╄→гoц情女王★ 提交于 2019-12-08 03:00:02
问题 In silverlight project that uses datagrid, I am using some column that defines "Label number" which is a Varchar. I want to sort this column as described in natural sort order as described in "http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting" or any possible way. When I look around datagrid I saw SortMemberPath="stringProperty" only. Hence, my sorting is just working like string sorting only. For example: Z1 Z10 Z2 Z20 where as I want it to sort like: Z1 Z2 Z10 Z20 It will be

how to sort strings in javascript numerically

痞子三分冷 提交于 2019-12-04 18:24:22
问题 I would like to sort an array of strings (in javascript) such that groups of digits within the strings are compared as integers not strings. I am not worried about signed or floating point numbers. for example, the result should be ["a1b3","a9b2","a10b2","a10b11"] not ["a1b3","a10b11","a10b2","a9b2"] The easiest way to do this seems to be splitting each string on boundaries around groups of digits. Is there a pattern I can pass to String.split to split on character boundaries without removing

Does Datatables' natural sort plugin work where data is got with server side processing?

隐身守侯 提交于 2019-12-04 06:05:08
问题 I got it to work with static html data as shown in this jsfiddle: http://jsfiddle.net/L7PNV/ by specifying aoColumns: {"sType": "natural"} where when I sort the first column it shows rows in right (natural-sorted) order: SIR_1_SIL_CGG_2011_224_SILAC1b_IMAC_Fr1 SIR_2_SIL_CGG_2011_224_SILAC1b_IMAC_Fr1 SIR_3_SIL_CGG_2011_224_SILAC1b_IMAC_Fr1 SIR_10_SIL_CGG_2011_224_SILAC1b_IMAC_Fr1 ... But then I want to apply natural sort to this same datatable where data is fetched server-side, the code where