Sorting Scripture References -


i'm working on csci capstone focusing on text-searching through bible and, because of nature of program, returning unordered list of scripture references formatted such: "nameofbook chapnum: versenum".

after list of references, need sort them on 3 fields: name, chapter, , verse, in order, , i'm hoping avoid using o(n^3) algorithm. have code sorts each reference on book name, o(n), don't know go here...

suggestions?

edit: i'm working in java arrays , looking @ storing sorted data text file can accessed later on.

if want have single sort name, chapter, , verse, can either set sort uses 3 of things key sorting, or can use "stable sort" , sort verse, chapter, name.

here's pseudocode in python. it's real python code except don't have definitions parse_code(), get_name(), get_chapter(), or get_verse().

lst = [] x in parse_code(input_file):     name = get_name(x)     chapter = get_chapter(x)     verse = get_verse(x)     tup = (name, chapter, verse)     lst.append(tup)  lst.sort()  # automatically want 

when have list made of tuples, , sort list, python sort based on first item in tuple, followed second, followed third.

on other hand, if trying build 3 different indexes, maybe simplest implementation stash data in database, , put index on each of name, chapter, , verse. use sqlite database; project size of text in bible think work well.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -