473,769 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sorting two arrays

this is prolly too simple but i got a brain block

i have two arrays, one is days[1-7] and the other is
timeofday[a-l],<each letter represents a time on the hour>
how do is sort by days and put each day's list in order of time?
so that i get a list in order of days and each day is in order of
time...i can put in order by day or time but they always end up with
whatever is the other order wrong.

if ( isset($_GET['sort']) && $_GET['sort']=='call_days' ) {
$_SESSION['sort'] = 'call_days'; }

if ( isset($_GET['sort']) && $_GET['sort']=='call_time' ) {
$_SESSION['sort'] = 'call_time'; }

and:

<?php if ($_SESSION['sort']!='call_time') { echo '<a
href="',$_SERVE R['PHP_SELF'],'?sort=call_ti me">Call Time</a>'; } else {
echo 'Call Time &darr;'; } ?>

<?php if ($_SESSION['sort']!='call_days') { echo '<a
href="',$_SERVE R['PHP_SELF'],'?sort=call_da ys">Call Days</a>'; } else {
echo 'Call Days &darr;'; } ?>

:-)^2
Jul 17 '05 #1
3 1853
I noticed that Message-ID:
<mB************ *******@bignews 4.bellsouth.net > from Terry Richards
contained the following:
i have two arrays, one is days[1-7] and the other is
timeofday[a-l],<each letter represents a time on the hour>
how do is sort by days and put each day's list in order of time?
so that i get a list in order of days and each day is in order of
time...i can put in order by day or time but they always end up with
whatever is the other order wrong.

if ( isset($_GET['sort']) && $_GET['sort']=='call_days' ) {
$_SESSION['sort'] = 'call_days'; }

if ( isset($_GET['sort']) && $_GET['sort']=='call_time' ) {
$_SESSION['sort'] = 'call_time'; }

and:

<?php if ($_SESSION['sort']!='call_time') { echo '<a
href="',$_SERV ER['PHP_SELF'],'?sort=call_ti me">Call Time</a>'; } else {
echo 'Call Time &darr;'; } ?>

<?php if ($_SESSION['sort']!='call_days') { echo '<a
href="',$_SERV ER['PHP_SELF'],'?sort=call_da ys">Call Days</a>'; } else {
echo 'Call Days &darr;'; } ?>


Maybe I have brain block too but that code seems to have nothing to do
with the question.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
Geoff Berrow wrote:
I noticed that Message-ID:
<mB************ *******@bignews 4.bellsouth.net > from Terry Richards
contained the following:

i have two arrays, one is days[1-7] and the other is
timeofday[a-l],<each letter represents a time on the hour>
how do is sort by days and put each day's list in order of time?
so that i get a list in order of days and each day is in order of
time...i can put in order by day or time but they always end up with
whatever is the other order wrong.

if ( isset($_GET['sort']) && $_GET['sort']=='call_days' ) {
$_SESSION['sort'] = 'call_days'; }

if ( isset($_GET['sort']) && $_GET['sort']=='call_time' ) {
$_SESSION['sort'] = 'call_time'; }

and:

<?php if ($_SESSION['sort']!='call_time') { echo '<a
href="',$_SER VER['PHP_SELF'],'?sort=call_ti me">Call Time</a>'; } else {
echo 'Call Time &darr;'; } ?>

<?php if ($_SESSION['sort']!='call_days') { echo '<a
href="',$_SER VER['PHP_SELF'],'?sort=call_da ys">Call Days</a>'; } else {
echo 'Call Days &darr;'; } ?>

Maybe I have brain block too but that code seems to have nothing to do
with the question.


well now, what i am looking to do is explained as best as i can. what
does this code do? i am thinking i need to do for each day:
(day[1-7])(time[a-l])starting with day1-a getting a total of 72
interations ending with (day7-l)

:-)^2

Jul 17 '05 #3
Terry Richards wrote:
Geoff Berrow wrote:
I noticed that Message-ID:
<mB************ *******@bignews 4.bellsouth.net > from Terry Richards
contained the following:

i have two arrays, one is days[1-7] and the other is
timeofday[a-l],<each letter represents a time on the hour>
how do is sort by days and put each day's list in order of time?
so that i get a list in order of days and each day is in order of
time...i can put in order by day or time but they always end up with
whatever is the other order wrong.

if ( isset($_GET['sort']) && $_GET['sort']=='call_days' ) {
$_SESSION['sort'] = 'call_days'; }

if ( isset($_GET['sort']) && $_GET['sort']=='call_time' ) {
$_SESSION['sort'] = 'call_time'; }

and:

<?php if ($_SESSION['sort']!='call_time') { echo '<a
href="',$_SERVE R['PHP_SELF'],'?sort=call_ti me">Call Time</a>'; } else
{ echo 'Call Time &darr;'; } ?>

<?php if ($_SESSION['sort']!='call_days') { echo '<a
href="',$_SERVE R['PHP_SELF'],'?sort=call_da ys">Call Days</a>'; } else
{ echo 'Call Days &darr;'; } ?>


Maybe I have brain block too but that code seems to have nothing to do
with the question.

well now, what i am looking to do is explained as best as i can. what
does this code do? i am thinking i need to do for each day:
(day[1-7])(time[a-l])starting with day1-a getting a total of 72
interations ending with (day7-l)


That makes it clear as a pint of Guiness... Show us the code that (1)
loads the arrays and (2) sorts them.

NM

--
convert uppercase WORDS to single keystrokes to reply
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2986
by: Paul Kirby | last post by:
Hello All I am trying to update me code to use arrays to store a group of information and I have come up with a problem sorting the multiple array :( Array trying to sort: (7 arrays put into an array) and I want to sort on Descending. This is displayed using print_r() function. Array
7
3266
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) CType(local4, Short) = CType(src, Short)
22
4168
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b) { return -1; } else
7
3050
by: Karin Jensen | last post by:
Hi I am running a PHP program that connects to an Access 2000 database via ODBC: $results = odbc_exec($connection_id, $sql_select); Is it possible to sort the contents of $results? I wish to use a regex-based sort order that you can't do in Access 2000* SQL with "ORDER BY".
16
3392
by: aruna | last post by:
Given a set of integers, how to write a program in C to sort these set of integers using C, given the following conditions a. Do not use arrays b. Do not use any comparison function like if/then or switch-case c. you can use pointers only d. you cannot use any of the loops either.
23
6351
by: yatindran | last post by:
hai this is my 2d array. int a = { {5,2,20,1,30,10}, {23,15,7,9,11,3}, {40,50,34,24,14,4}, {9,10,11,12,13,14}, {31,4,18,8,27,17}, {44,32,13,19,41,19}, {1,2,3,4,5,6},
10
455
by: Roy Gourgi | last post by:
Hi, How would I sort an array? TIA Roy
3
2193
by: SneakyElf | last post by:
i am very green with c++ so i get stuck on very simple things anyway, i need to write a program that would read data from file (containing names of tv shows and their networks) one line at a time ( ; separates tv show and network) sort the strings according to the network and according to the show. and so: //to open file - ifstream myFile;
3
7346
KevinADC
by: KevinADC | last post by:
If you are entirely unfamiliar with using Perl to sort data, read the "Sorting Data with Perl - Part One and Two" articles before reading this article. Beginning Perl coders may find this article uses unfamiliar terms and syntax. Intermediate and advanced Perl coders should find this article useful. The object of the article is to inform the reader, it is not about how to code Perl or how to write good Perl code, but to teach the Schwartzian...
5
3186
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The search algorithms that can be used are Linear Search and Binary Search. The sorting algorithms are bubble, selection and Insertion sort. First, the user is asked whether he/she wants to perform a search option, a sort operation, or exit the program. If...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.