Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7081551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:56:06+00:00 2026-05-28T06:56:06+00:00

Given such data UserID, MovieType , year 1, 2, 2000 1, 3, 2000 1,

  • 0

Given such data

UserID, MovieType , year 
1, 2, 2000
1, 3, 2000 
1, 2, 2006
2, 3, 2010
2, 4, 2011
2, 3, 2002
1, 2, 2010

What are the best option to store it in java , such that I can sort it according to first column , then second column then third ?

UserID, MovieType , year 
1, 2, 2000
1, 2, 2006
1, 2, 2010
1, 3, 2000 
2, 3, 2002
2, 3, 2010
2, 4, 2011

And then group them by user ID and Movietype

UserID, MovieType , movies seen per year  
1, 2, 3
1, 3, 1 
2, 3, 2
2, 4, 1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:56:06+00:00Added an answer on May 28, 2026 at 6:56 am

    For a very specific solution, you could have a Map<Integer, Map<Integer, Integer>>.

    The first Map stores UserIDs to a map that stores MovieTypes to MoviesSeenPerYear.

    If you use a TreeMap as the underlying types, everything will automatically be numerically sorted.

    This will not be very flexible, though – for example, it would be difficult if you wanted to re-sort by MovieType instead of UserId.


    In response to your comment:

    You will have 2 main limitations:

    1. All of the Java collections classes are based on int sizes (same as the Java’s array indexer), which have a maximum size of just under 2^31-1, or 2,147,483,647 – or just over 2 billion entries.
    2. Memory limitations of your JVM / machine.

    If you’re looking at working with this much data, and would like more flexible sorting requirements, you’d be well advised to use an actual database – either one of the standard ones, or even a JVM-embedded one like H2 or Apache Derby.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given data such as : user, library ID, book ID, year 1,10, 100,2000 2,10,
Given an InputStream called in which contains audio data in a compressed format (such
Hey guys, given a data set in plain text such as the following: ==Events==
In MS SQL 2000 and 2005, given a datetime such as '2008-09-25 12:34:56' what
Given data such as Type Value A This A is B Will A a
Given such data: #Cutpoint SN (1-PPV) 5 0.56 0.01 7 0.78 0.19 9 0.91
How to best store user data vs date/time dimension? Usecase is I am trying
struct node { void *data; struct node *link; }; Given such a structure we
Given a path such as "mydir/myfile.txt" , how do I find the file's absolute
Given a point such as (0, 0, 0) and a vector like (x, y,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.