You are here:

# Qbasic, Quickbasic/sort a two-DIM array

Question
How do I sort the years in ascending order?

100   DIM Q\$(75,3)
110   FOR R = 1 TO 75
120   FOR C = 1 TO 3
140   NEXT C
150   NEXT R

---          SWAP ?

190   FOR R = 1 TO 75
200   FOR C = 1 TO 3
210   PRINT Q\$(R,C)
220   NEXT C
230   NEXT R
240   DATA  "12/20/2014", "Bin:A,Loc.C", "Qty.:20"
241   DATA  "01/31/2015", "Bin:Z,LOC.A", "Qty.:110"
242   DATA  "11/22/2014", "Bin:V,Loc.B", "Qty.:09"
243   DATA  "12/18/2013", "Bin:H,Loc.T", "Qty.:14"
244   DATA  "02/14/2015", "Bin:K,Loc.G", "Qty.:100"
.
.
380   END

Thanks,
Rashid

Hi Rashid,

You should look up the documentation on the SWAP statement.

Here is an example:

DIM a%
DIM b%

a% = 876
b% = 101

PRINT a%, b%
REM 876     101

SWAP a%, b%

PRINT a%, b%
REM 101     876

I hope this helps,

-Alex

Qbasic, Quickbasic

Volunteer

#### Alex Barry

##### Expertise

I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, QB64, c/c++, python, lua, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

##### Experience

I have been programming in *Basic dialects since 2000, as mentioned in my expertise. After a year of QBasic, I learned C and C++, and dabbled a little in ASM (I don't program in ASM - I literally just played around to see how things work). When QB64 and FreeBASIC were released, I played with those languages. At the time, FreeBASIC offered more functionality and I sided with that language for a while. During that time, while I was learning new languages, that I would see what scripting languages are available, where I took up python and lua. I started to notice a staleness to QB64's development (which I kept tabs on from time to time), and am now trying to be active in it's community and maybe in it's development in the future. Currently, I am only active on the QB64.net forums, but I appear on occasion on FreeBASIC.net's forums as well.

Education/Credentials
Highschool - 2007