**Array sort function sorts on chars not numbers ... help ! how to sort numbers**My question is ... How do I sort an Array on numeric, not character values ?
In the example below, after sorting the contents are 1,10,2,3 .
How do I get the contents to be 1,2,3,10 ?
Thanks,
em
<html>
<head>
<script>
function TestSort() {
var nums = new Array(0);
nums[0] = 1;
nums[1] = 2;
nums[2] = 10;
nums[3] = 3;
nums.sort();
for ( i = 0 ; i < 4 ; i++ ) {
alert(nums[i]);
}
return true;
}
</script>
</head>
<body bgcolor="lightblue">
<input type="button" onclick="TestSort();&quo...

**Sorting Numberic keys in a hash array**I had some code that would sort my keys in ascending order - no
problem.
Now what I have found is that when I introduce new values which are 6
digits (rather than 5 digits), it will place these are the beginning of
the list because they begin with the number 1.
My code is:
foreach $PackageToDeploy (sort(keys(%AparsToApply)))
{
print
"\t${PackageToDeploy}\t-\>\t$AparsToApply{$PackageToDeploy}\n";
}
which will produce the following:
57414 -> server1
57441 -> server1
57451 -> server1
57483 ...

**Determining if there are 2 numbers in a sorted array which add up to particular number.**Given a non-decreasing array of numbers, A and an arbitrary number,
k, is it possible to determine in linear time, whether there exists
integers i and j such that A[i]+A[j] = k? I wasn't able to come up
with any algorithm better than nlg(n).
Sabyasachi.
"Sabyasachi Basu" <sabya_003@yahoo.com> wrote:
> Given a non-decreasing array of numbers, A and an arbitrary number,
> k, is it possible to determine in linear time, whether there exists
> integers i and j such that A[i]+A[j] = k? I wasn't able to come up
> with any algorithm better than nlg(n).
> Sa...

**removing certain values from an array and then sorting the array for another variable**Hi!
i have an array that has the dimensions, areas and shear stresses of a certain cross section (I beam), however i need to ignore certain combinations (as the stress for a calculated area is larger then the allowed stress), and then once this is done, find the minimum area
column 1 is the ratio of stress/stress_allowed (therefore, want values from 0.9 - 1 to ensure minimum area)
column 2 is the area of the cross section
column 3 is the height of the cross section
column 4 is the width of the cross section
so,
need to eliminate all rows where column1 is less 0.9 and greater then 1
then fr...

**manually sort array of numbers**for the sake of learning, I built a sort method to sort an array of
numbers manually rather than with the built-in Array#sort method.
below is my code. Would you say this is a "good" way to do it?
def sort_array(array)
i = 0
while i < array.length do
index_max = max_array_index(array, array.length - i)
temp = array[index_max]
array[index_max] = array[array.length - i - 1]
array[array.length - i - 1] = temp
i += 1
end
return array
end
def max_array_index(array, size)
i = 1
i_max = 0
while i < size do
if array[i] > array[i_max] then
...

**sort() array names sequentially with numbers**
Hi all, A while back I asked how to sort an array of strings which would
have numerals and I wanted to put them in sequential numerical order.
For example:
myArray[0] = "file1";
myArray[1] = "file2";
myArray[2] = "file3";
myArray[3] = "file4";
myArray[4] = "file5";
myArray[5] = "file6";
myArray[6] = "file7";
myArray[7] = "file8";
myArray[8] = "file9";
myArray[9] = "file10";
myArray[10] = "file11";
etc...
However using the normal sort function below for numerical sorting...
------...

**Sorting numbers based on value into arrays**Hi ...
I currently have a large list of numbers inside an array.. say from 0 to 400 000. They appear in order, but are unevenly spaced.
Now I'd like to sort these numbers into arrays.
I want to say: Put all numbers from 0 to 10 into newArray[0]. Put all numbers from 10 to 35 into newArray[1] ....
In the end I need a two - dimensional array with numbers. Is this possible in LabView ? Can it be done in acceptable speed ?
Thank you for your help :)
or does anyone see why this doesn't wo...

**Creating an array with incrementing values up to a certain number**[Note: parts of this message were removed to make it a legal post.]
Hello,
Another basic question, thanks for the help on the last one. I wanted to
come up with the above described program and came up with this:
# array.rb start
a = [1]
x = 0
while x < 99
a[(x+1)] = (a[x] + 1)
x = x + 1
end
p a
# array.rb end
This worked fine, but is there a more elegant way of doing this? It seems a
bit clumsy.
Brian
irb(main):004:0> i = 0
=> 0
irb(main):005:0> a = Array.new(99){i+=1}
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24...

**Query**Hi, I am trying to figure out a way of ordering my results
alphabetically but also starting by a particular letter or number. To
give an example, a user searches for the letter 'c', the query will
give every everything with a 'c' in the title of the product. I would
like the results to be sorted alphabetically starting with the 'c' or
whatever single letter or number they choose, is this possible?
On 29 Nov, 10:14, supp...@avcserver.com wrote:
> Hi, I am trying to figure out a way of ordering my results
> alphabetically but also starting by a particular letter or...

**How to find number of times certain conditions happened in an array?**Dear Gurus,
I would like to implement a function that computes the number of times
a certain condition is met in a global array.
For example, I have an global array of size 500.
float array[500];
I have a function that finds the maximum of an array of size 50.
bool findMax50(float input[])
Next, I want to implement a function that can do the following;
Sum( findMax50(array), period)
If period is 20, then this function will start at the last element of
the global array and will return 1 if this element is a maximum among
the 50 elements it covers. Then, it moves on to the (last -1)th
eleme...

**get a certain number of elements out of a cell with cell arrays**did anybody know a solution to get a certain number of elements out of a cell with cell arrays.
for example: splits 6x1 cell filled with
splits =
{1x3 cell}
{1x2 cell}
{1x3 cell}
{1x3 cell}
{1x4 cell}
{1x3 cell}
how can i get from each cell the 1-3 element with a command without a loop?
(if there are only 1 or 2 elements the result should look like this [1] [] [] or [1] [2] [])
"Sebastian " <mammoth@gmx.at> wrote in message <hjqi81$m9b$1@fred.mathworks.com>...
> did anybody know a solution to get a certain number of elements out of a ce...

**[LogoForum] Re: Number format, sorted lists, arrays and other herbs**The message below is being cross-posted from LogoForum.
> 1) Daniel, about the number formats, your procedure works so fine
> about the decimal part separation but, What about the thousands?
I'm not going to give you an answer for this one. I'm just going
to show how I would do it using LogoFE:
es desmarca list ", "3141592653589,79
[3141592653589 79]
show refleja "3141592653589
[9 8 5 3 5 6 2 9 5 1 4 1 3]
show segmenta list 3 refleja "3141592653589
[[9 8 5] [3 5 6] [2 9 5] [1 4 1] [3]]
show impon [endosa "lput list ".] segmenta list 3 refleja ...

**Re: I need to sort an array of strings based on the number in each string.**It's a while since this thread was started, but I am sure others will have use for this so here goes:
The in-built array sort function sorts the strings the same way DOS and Windows do. Microsoft has fixed this in the Explorer that comes with XP, however the rest of the OS(s) still sorts the old way.
The attached "AlphaLogical String Array Sort" VIs will sort strings arrays the same way as the new XP Explorer. There are three different implementations of the sorting, one based on the Insertion sort algorithm, a Quick Sort based on recursive calls (...

**[LogoForum] Re: Number format, sorted lists, arrays and other herbs #2**The message below is being cross-posted from LogoForum.
HI LOGO FANS!!!!!!!
Thank you so much Daniel, Brian and all the others. You have
contributed a lot to help to increase my Logo knowledge!!!
But, a lot of points:
1) Daniel, about the number formats, your procedure works so fine
about the decimal part separation but, What about the thousands?
2) About the sorted lists and arrays, I didn't understand the
Daniel's way but... it works!!! With the old Atari Logo (in 1985) I
wrote a way to sort a list, but we must to translate all the
characters of the list to ASCII number code. Th...

**Sorting array against other array**Say I have two arrays with the same number of elements that are related:
var a1 = [1,3,2];
var b2 = ["a","b","c"];
I need to sort a1 but have the order of the elements in b2 reflect the
any new order in a1. So if a1 sorts as
[1,2,3] then b2 becomes
["a","c","b"]
or if a1 sorts as
[3,2,1] then b2 becomes
["b","c","a"]
Andrew Poulos
Andrew Poulos said:
>
>Say I have two arrays with the same number of elements that are related:
>
>var a1 = [1,3,2];
>var b2 = ["a","b&qu...

**sort array of array**Dear all,
I have found quick sort codes and modified them to sort an array of
structure. Because I have many such rows to be sort, the input is indeed
array of "array of structure".
I have been confused with the *, [], **, &, and so. Could anybody help me
about what should be changed in order to get the sorting done?
====================================
In abc.h
struct tagged_array {
/*
int oldtag[SIZE];
int newtag[SIZE];
float value[SIZE];
*/
int oldtag;
int newtag;
float value;
};
void qs_struct(struct tagged_array items[], int, int);
void quick...

**Sorting through an array of an array**Hello.
Each of my arrays look like this:
container[0] = ["foo", "bar", "baz"]
container[1] = ["doo", "poo", "woo"]
i'd like to sort by the second position (bar, and poo)
and of course,affecting the whole row, so that "bar" should be on top,
along with "foo" and "baz" as container[0].
What method should i use?
Thanks
--
Posted via http://www.ruby-forum.com/.
In article <1a701a2f74c6f4245c0092667a764972@ruby-forum.com>,
Dominic Son <dominicson@gmail.com> wrote:
>Hello.
>
&g...

**How can I extract the numbers from an array and diplay each one as a number rather than in an array**Hi
I am having a mad moment.
All I want to do is break my 1d numeric array into seperate numbers so they can be represented as single number numeric indicators. If I use the delete from array function the number is still represented in an array.
Very easy answer I am sure but little things like this drive us crazy.
Ash
Don't use "delete from array", it is not useful for this and very inefficient. Use "index array", it is resizeable. :)
<img src="http://forums.ni.com/attachments/ni/170/191...

**Find all indexes of numbers in an array that are equal to 'any' number in another array**a = [ 2 1 3 6 4 ];
I need to find the indexes of 1 and 6 in 'a'.
I tried find( a == [1 6] ) but it gave the following error:
??? Error using ==> eq
Matrix dimensions must agree.
One way is to find 1 and 6 individually but that is not optimal. I was wondering if there is a quick way to do it other than using 'for loop'.
"Shahzad " <shahraj81@yahoo.com> wrote in message
news:i8cso6$9db$1@fred.mathworks.com...
> a = [ 2 1 3 6 4 ];
>
> I need to find the indexes of 1 and 6 in 'a'.
> I tried find( a == [1 6] ) but it gave the...

**Sorting problem with an Array of Arrays**Hi there, I have an array of arrays that looks like the following:
arr1 = [["ABC-1", 1271768400, 2], ["ABC-2", 1271773800, 1],
["ABC-3", 1271863200, 2], ["ABC-4", 1271869200, 2],
["AAA-1", 1271862000, 2], ["DEF-1", 1271772000, 1]]
Desired sort order:
(1) label (1st element = all unique)
(2) different labels (e.g. AAA, DEF) need to be inserted according to
timestamp (2nd element), but maintain (1) label sort order; so AAA-2
can't come before AAA-1. (I don't have that data point here but it
happens)
=> I ...

**Sorting an array by another array**I want to sort an array by the order the elements appear in a second
array. For example suppose I have:
$array1 = qw ( item-a item-b );
$array2 = qw ( item-b3 item-a2 );
I would like to sort array2 by array1 so array2 becomes:
item-a3, item-b2
Is there any easy way to do it withouth brute force way of comparing
every
element in array2 with every element in array1?
el_roachmeister@yahoo.com wrote:
> I want to sort an array by the order the elements appear in a second
> array. For example suppose I have:
Give real data, it makes talking about it easier.
> $array1 = qw ( item...

**sort number with deleting the same number**Hi all...
How can I sort the number and delete the the number which has the
same number
for ex:
a= 3 5 2 4 3 4 4
into
a=2 3 4 5
thanks alot
P� Wed, 16 Feb 2005 01:19:45 -0500, skrev wahyu <addy_w33@yahoo.com>:
> Hi all...
>
> How can I sort the number and delete the the number which has the
> same number
>
> for ex:
> a= 3 5 2 4 3 4 4
>
> into
> a=2 3 4 5
>
> thanks alot
help unique
--
K
Hi,
a=[3 5 2 4 3 4 4];
a=sort(unique(a))
J�r�me
J�r�me wrote:
>
>
> Hi,
>
> a=[3 5 2 4 3 4 4];
> a=sort(unique(a))
>
> J�r�me
>...

**String of numbers into to array of numbers**Hi All,
My goal is to take a string of numbers separated by commas
then read that string and have the string show the
individual numbers as in an array. This is a small
demo of my problem.
Your help is appreciated.
bH
import javax.swing.*;
public class Whatsup extends JFrame {
JPanel infoPanel= new JPanel();
int cInt[] = new int [9];
void Whatsup() {
String cStr = "";
cStr = "84,104,101,32,67,108,111,99,10";
System.out.print(" The string is = "+ cStr);
for(int i = 0;i<9;i++) {
//cInt[i] = Integer.getInteger(cStr); //does not work...

**Sort order of a sorted array**With the PHP command 'sort' I can sort an array. However, it doesn't exactly
sort the array I'd like to:
<html>
<body>
<?php
$my_array[0] = array("AA", "11");
$my_array[1] = array("AA", "22");
$my_array[2] = array("aa", "22");
$my_array[3] = array("AB", "11");
$my_array[4] = array("ab", "11");
$my_array[5] = array("ab", "22");
$my_array[6] = array("�b", "11"...