ruby - How to calculate median in a Rails app that uses SQLite3? -


is there way median calc in rails 4 app uses default sqlite3 database?

i've built app add median function, , see active_median gem works postgresql now:

https://github.com/ankane/active_median

try calculate median

def median(array)   sorted = array.sort   len = sorted.length   return (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0 end 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -