Frame sorting code
using Black Frequency