• PicŪ Basic

  • BubbleSort

    A library module for use withLibrary Manager by JohnGB. This module has been written by Tim Box (Tim on PDS forum). The library module is offered on an as-is basis with no warranty as to its effectiveness, operation or reliability. Users use it at their own risk.

    Adds a new command called BubbleSort


    BubbleSort Array, Elements, Direction


    Performs a bubble sort on N number of elements on a byte array in either direction.


    Array – any Byte array

    Elements - a constant, or byte variable indicating the number of elements within the array to sort

    Direction - a constant, or byte variable indicating the direction of sorting 0 or 1. Any number > 0 will be taken as 1. 1 = high numbers first, 0 = low numbers first

    Include "proton_4.inc""   
        Dim myarray[10] As Byte
        Dim index As Byte
        For index = 0 To 9
            myarray[index] = index
            HRSOut Dec myarray[index],", "
        HRSOut 13,10 
        index = 1 
        BubbleSort myarray, 10, index
        For index = 0 To 9
            HRSOut Dec myarray[index],", "
        HRSOut 13,10
        index = 10
        BubbleSort myarray, index, 0 
        For index = 0 To 9
            HRSOut Dec myarray[index],", "
        HRSOut 13,10
    The above example code will fill an array with the values from 0 to 9 and send then sort the array first down then up.

    Download module

    Download: Bubble Sort
  • Recent Activity


    Mysterious PORTB problem

    Thread Starter: xldaedalus

    I'm using Proton+ to develop firmware for a product with switches. The MCU is an 18F26K22. Most of the switches reside on PORTB. I am NOT using a...

    towlerg Yesterday, 15:45 Go to last post

    PIC18F1330 PLL problem

    Thread Starter: rcurl

    I'm just starting out on a new project that uses a PIC18F1330. I haven't used this specific chip before, so I began by trying to blink an LED just...

    rcurl Today, 12:59 Go to last post

    Pic16f18877 oread

    Thread Starter: evoortman

    Hi, On a PIC16F18877 the OREAD command doesn't seem to work. The code is working on a PIC16F1939. Both controllers use 32MHz int osc. If i...

    evoortman Today, 14:11 Go to last post

    MID$ Problem with a PIC18F25K22

    Thread Starter: palamont

    Hi everybody, I encounter a strange problem : I have a string of 230 characters. This string is divided into 10 segments of 23 characters, with a...

    palamont Today, 10:08 Go to last post