CAPTCHA
Image CAPTCHA
Enter the characters shown in the image.
This question is for testing whether or not you are human.
  • Create new account
  • Reset your password

User account menu

Home
The Hyperlogos
Read Everything

Main navigation

  • Home
  • My Resumé
  • blog
  • Howtos
  • Pages
  • Contact
  • Search

Crystal Reports 9: Insertion Sort

Breadcrumb

  • Home
  • Crystal Reports 9: Insertion Sort

Given that Crystal has no array-sorting functions, there is often a need to write one. An insertion sort is the most efficient of the particularly simple and short sort algorithms, working well with short sets, whether they are already substantially sorted or not.

Shared NumberVar Array foo;
Local NumberVar i := 2;
Local NumberVar j;
Local NumberVar length := ubound(foo);
Local NumberVar value;
//
while ( i <= length )
do
(
  value := foo [i];
  j := i - 1;
  while ( j >= 1 and foo [j] > value )
  do
  (
    foo [j + 1] := foo [j];
    j := j - 1;
  );
  foo [j + 1] := value;
  i := i + 1;
);

An example report is available which demonstrates this sort algorithm.

Attachment Size
insertion-sort.rpt_.gz (3.02 KB) 3.02 KB
database
howto
crystal reports
  • Log in or register to post comments

Footer menu

  • Contact
Powered by Drupal

Copyright © 2025 Martin Espinoza - All rights reserved