Print Page | Close Window

Sorting an Array

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9701
Printed Date: 03 May 2024 at 8:29am


Topic: Sorting an Array
Posted By: ajmufic
Subject: Sorting an Array
Date Posted: 15 Apr 2010 at 4:36am
Is there an easy (or hard) way to sort an Array in Crystal Syntax?



Replies:
Posted By: lockwelle
Date Posted: 16 Apr 2010 at 4:35am
probably any sort algorithm you want, but there are limits to the arrays, only 1d.  Can use loops and swap values to sort.
 
something like this should swap:
 
if arr[x]<arr[y] then (
  temp := arr[y];
  arr[y] := arr[x];
  arr[x] := temp;
);
 
 
look up loops, and you will probably want a flag that a swap has occurred, so when none are performed, you know that you are done.
 
HTH


Posted By: kevlray
Date Posted: 16 Apr 2010 at 4:43am
Bubble sort probably would work.  I haven't done one in a few years (okay, a lot of years).


Posted By: joelum
Date Posted: 11 Nov 2010 at 10:11am
See my PPT presentations using bubble sort algorithm at http://www.sfarea.org/12201.html - http://www.sfarea.org/12201.html
 
For arrays under 445 rows, see Nov 2008 meeting (easy)
 
For arrays from 1 to 1000 rows due to 99,999 loop limitations,
see Oct 2010 meeting (hard but rigorous)


-------------
joelum



Print Page | Close Window