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

xslt - Substring before throwing error -

Google Cloud Bigtable Durability/Availability Guarantees -

Android M doze mode and "native" posix socket freezing up -