function sortData(newDataArray) { 
                  
                        let currentRawMinChunk = undefined
                        let rawMinChunks = []
                        //console.log("this is our new data", newDataArray)
                        try { 

                            if (mustLoadRawData) { 
                                let startingDate = new Date(initialProcessTimestamp)
                                
                                let firstDataRow = newDataArray[0]
                                let currentTimestamp = validateRawTimestamp(firstDataRow[dbTimestamp])
                                
                                if(checkIfOnSameDay(startingDate, currentTimestamp)) {
                                // Check if the raw chunk associated with the last day file overlaps with the day of our new min chunk
                                
                                    // Check if we can access the old raw minute chunk to load and aggregate with our current data 
                                    let fileName = "Data.json"
                                    let filePath = getFilePath(initialProcessTimestamp, RAWDATA_FOLDER_NAME)
                                    let fullFileName = filePath + '/' + fileName;
                                    let fullFilePath = global.env.PATH_TO_DATA_STORAGE + '/' + fullFileName;
                                    console.log(fullFilePath);

                                    if (SA.nodeModules.fs.existsSync(fullFilePath)) {
                                    // If it does we load it and start the sorting process
                                        SA.logger.info(MODULE_NAME + " processAndSaveMessages - > sortData -> loading saved raw minute chunk from file = " + fullFileName)
                                        currentRawMinChunk = JSON.parse(SA.nodeModules.fs.readFileSync(fullFilePath, 'utf8'))
                                        rawMinChunks = toRawOneMinChunks(newDataArray, currentRawMinChunk)
    
                                    } else {
                                        SA.logger.warn("old saved raw minute chunk not found")
                                        mustLoadRawData = false
                                        rawMinChunks = toRawOneMinChunks(newDataArray, undefined)
                                    }
                                } else {
                                    // if not on the same day we sort for a new day file
                                    mustLoadRawData = false
                                    rawMinChunks = toRawOneMinChunks(newDataArray, undefined)
                                }
                            } else {
                                // if we do not then we sort into chunks without any starting raw chunk
                                rawMinChunks = toRawOneMinChunks(newDataArray, undefined)
                            }

                            /**
                             * The function takes in new data and sorts it into one minute chunks based
                             * on timestamps.
                             * @param newDataArray - An array of new data to be sorted into minute
                             * chunks.
                             * @param oldRawChunk - The previous raw one minute chunk that was being
                             * processed before the new data was added. It is undefined if this is the
                             * first time the function is being called.
                             * @param rawMinChunks - An array that contains the sorted data in one
                             * minute chunks. Each element in the array represents a one minute chunk
                             * and contains an array of data rows that fall within that minute.
                             * @returns an array of sorted data chunks based on one minute intervals.
                             */
                            function toRawOneMinChunks(newDataArray, oldRawChunk) {
                                // We take in new data and sort it according to minute chunks
                                let rawTimestamp
                                let currentTimestamp
                                let currentRawChunk = oldRawChunk
                                let chunksArray = []

                                for (let row of newDataArray) {
                                    // make sure the timestamp is formatted correctly to be accepted by the date object
                                    rawTimestamp = row[dbTimestamp]
                                    currentTimestamp = validateRawTimestamp(rawTimestamp)
                                    currentNewData = row
                                    
                                    /* Reporting we are doing well */
                                    logAndHeartBeat(currentTimestamp, ' Sorting data ', newDataArray, row)

                                    if (currentRawChunk === undefined) {
                                        // This means we have just started the sorting process so we create an new raw one minute chunk and add the incoming data row
                                        currentRawChunk = newRawMinChunk(currentTimestamp, currentNewData)
                                        continue

                                    } else {
                                        // check to see if this timestamp fits in the current raw min chunk or not
                                        let unixTimestamp = currentTimestamp.getTime()
                                        if ( unixTimestamp >= currentRawChunk[0] && unixTimestamp <= currentRawChunk[1]) {
                                            // add to the current raw min chunk
                                            currentRawChunk.push(currentNewData)
                                            continue

                                        } else if (unixTimestamp > currentRawChunk[1]) {
                                            // Add previous raw min chunk to the array before we start a new chunk
                                            chunksArray.push(currentRawChunk)
                                            currentRawChunk = newRawMinChunk(currentTimestamp, currentNewData)
                                            continue

                                        } else {
                                            SA.logger.error("Timestamp is out of order: ", currentTimestamp, " Expected to be after ", currentRawMinChunk)
                                        }
                                    }
                                }

                                chunksArray.push(currentRawChunk)
                                // After the loop has finished push the last raw min chunk to the array
                                return chunksArray
                            }

                            /**
                             * The function creates a new array representing a single minute chunk of data
                             * with a given timestamp and data row.
                             * @param currentTimestamp - A JavaScript Date object representing the
                             * current timestamp.
                             * @param currentNewData - The data row that needs to be added to the
                             * minute chunk.
                             * @returns an array containing the start and end timestamps of a minute
                             * chunk, as well as a data row that fits within that minute chunk.
                             */
                            function newRawMinChunk(currentTimestamp, currentNewData) {
                                let newRawMinChunk =[]
                                
                                let begin = currentTimestamp
                                begin.setSeconds(0, 0)
                                // always put the begin property at the beginning of the minute chunk array
                                newRawMinChunk.splice(0, 0, begin.getTime())

                                let end = currentTimestamp
                                end.setSeconds(0, 0)
                                end.setMinutes(currentTimestamp.getMinutes() + 1)
                                // always put the end property in the second spot of the minute chunk array
                                newRawMinChunk.splice(1, 0, end.getTime())

                                // Add data row that fits within the minute chunk
                                newRawMinChunk.push(currentNewData)
                              
                                return newRawMinChunk
                            }

                        } catch (err) {
                            TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).UNEXPECTED_ERROR = err
                            TS.projects.foundations.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
                                "[ERROR] start -> saveOHLCVs -> err = " + err.stack);
                            callBackFunction(TS.projects.foundations.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
                            //abort = true
                        } 

                        return rawMinChunks
                    }
The function sorts new data into one minute chunks based on timestamps .
@param newDataArray - An array of new data to be sorted into one minute chunks
based on timestamps.
@returns The function `sortData` returns an array of sorted data chunks based on
one minute intervals.